Using AppleScript to sort files Into Specified Folders based on Extension
Hi All!
Here is what I am trying to figure out. I would love some help with this script if anyone can lend a helping hand. I am currently using Hazel to do this but I think AppleScript will be alot more effective.
Situation:
- I have a folder with 4 different file types inside - the extensions are (.cop, .cof, .cos, .cr2)
- These files need to be organized in this folder structure Captureone > Cache > Proxies
> Settings50
- The .cop & .cof files both need to be put in the "Proxies" folder
- The .cos needs to be put in the "Settings50" folder
- The .cr2 can stay where it is.
I'm already using an AppleScript application where it automatically creates the folder structure in the current finder location, which works great. I use a program named Hazel to sort the files automatically into the folders where they need to go. Unfortunately all my computers at work don't have Hazel and I would like help to make a script. Any thoughts to add to my existing script?
# define a list of folders - items will need to be quoted if they contain spaces, etc.
property theFolders : {"Captureone/Cache/Proxies", "Captureone/Settings50"} -- can also nest, e.g. "Inside/One"
try
tell application "Finder" to set targetFolder to (target of the front window) as alias
on error -- no window
set targetFolder to (choose folder)
end try
# build a parameter string from the folder list
set {tempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, space}
set {theFolders, AppleScript's text item delimiters} to {theFolders as text, tempTID}
do shell script "cd " & quoted form of POSIX path of targetFolder & "; mkdir -p " & theFolders
MacBook Pro, Mac OS X (10.6.8)