on run
set chosen_folders to choose folder with multiple selections allowed
open chosen_folders
end run
on open theseItems
repeat with oneFolder in theseItems
set {folder:Fo, package folder:Pa} to info for oneFolder
if Fo and not Pa then
tell (a reference to my text item delimiters) to set {old_delim, contents} to {contents, "."}
tell application "Finder"
try
set file_list to files of oneFolder
on error
set file_list to {}
end try
repeat with this_file in file_list
set folder_name to name of this_file
if folder_name contains "." then set folder_name to ((text items 1 thru -2 of folder_name) as string)
set new_folder to ((oneFolder as string) & folder_name & ":")
try
get new_folder as alias
on error
make new folder at oneFolder with properties {name:folder_name}
end try
move this_file to folder new_folder
end repeat
end tell
set my text item delimiters to old_delim
end if
end repeat
end open
I haven’t tested this, you can drop files or folders or choose folders by double-click it
on run
set chosen_folders to choose folder with multiple selections allowed
open chosen_folders
end run
on open theseItems
repeat with oneItem in theseItems
set {folder:Fo, package folder:Pa} to info for oneItem
if Fo and not Pa then
tell application "Finder" to set file_list to files of oneItem
repeat with oneFile in file_list
processFile(oneFile as alias, oneItem)
end repeat
else
tell application "Finder" to set parentFolder to container of oneItem
processFile(oneItem, parentFolder as alias)
end if
end repeat
end open
on processFile(this_file, oneFolder)
tell (a reference to my text item delimiters) to set {old_delim, contents} to {contents, "."}
tell application "Finder"
set folder_name to name of this_file
if folder_name contains "." then set folder_name to ((text items 1 thru -2 of folder_name) as string)
set new_folder to ((oneFolder as string) & folder_name & ":")
try
get new_folder as alias
on error
make new folder at oneFolder with properties {name:folder_name}
end try
move this_file to folder new_folder
end tell
set my text item delimiters to old_delim
end processFile
This script is such a timesaver for me … but here I am trying to tweek it even more … and failing. I’m running it on a Tiger 10.4.11 machine (t’s a long story) and I’m trying to have the script add a Finder Label (colour) to the newly created Folders.
Am I correct in thinking that I cannot do this with the Applescript under Tiger?
When I opened the Finder’s dictionary in Script Editor, it says ‘NOT AVAILABLE YET’ for Labels … so I guessed it wouldn’t work. Either way though, I’d never have managed to fluke the correct code. Ho hum. If ever you need advice about photography … just let me know.