Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

J.Henning

macrumors newbie
Original poster
Oct 18, 2014
4
1
Stockholm
Hello People!
I got a gigantic task i would like to simplify with a bit of Applescript.

Basically i'd like to move or copy a lot of files to a new folder structure.

I have a few different folders with about 500-4000 jpg's, see image below.
First image shows old structure, 2nd image show the new structure i would like to accomplish.
J2exDSd.jpg

96M0Vwn.jpg


What i would like to do is have a script loop through and take the first 4 characters of the filename and create a folder with that name in the location of my choosing. Then create a new folder in the parent folder called JPEG and copy all the files with that specific name to that folder.

So far i have been able to automate the creation of folders and sub-folders.
Any help is very much appreciated!

Code:
set loc to choose folder "Choose Parent Folder Location"

repeat with i from 1 to 3
    set j to text -2 through -1 of ("0" & i as text)
    try
        tell application "Finder" to set targetFolder to make new folder at loc with properties {name:"61" & j}
        tell application "Finder" to make new folder at targetFolder with properties {name:"JPEG"}
        tell application "Finder" to make new folder at targetFolder with properties {name:"PSD"}
    end try
end repeat
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.