I’m a photographer and in my workflow I always end up creating subfolders to sort my selection, unselec, converted, web files etc.
I also use a [job #][ClientName][date] (yyyymmdd format) string for naming my main folder. The job # is always 6 digits (08, year) followed by a dash and a 3 digit number
In my dreams I’d like PhotoMechanic (the image browser I use) to create subfolders within the main folder I’m putting the files into, but that’s too far fetch…
What I’m looking to do is : (see example)
08-062_ClientName_20080515 “ this is my main folder (the name of the main folder is created at download by my image browser)
At the end of the files download, I’d like to right click within the main folder and have the script create subfolders with only the “062” part of the job number followed by subfolder’s name.
.\062_raw select
.\062_unselect
.\062_converted (then 2 subfolders .\jpeg hi-res and .\jpeg low-res)
.\062_web
Many thanks in advance for your time reading this request.
Hugo-S. Aubert
MBP 2.2 GHz & G5 tower dual 2.3 GHz both running 10.5.2
Model: MBP 2.2 GHz & G5 tower dual 2.3 GHz both running 10.5.2
AppleScript: 2.2
Browser: Safari 525.18
Operating System: Mac OS X (10.5)
Hi,
try this, select the main folder in the Finder and run the script
try
tell application "Finder"
set sel to item 1 of (get selection) as alias
set {thePath, theName} to {POSIX path, its name} of sel
end tell
set jobNumber to text 4 thru 6 of theName
do shell script "/bin/mkdir -p " & quoted form of thePath & "/{" & jobNumber & "_raw\\ select," & jobNumber & "_unselect," & jobNumber & "_web," & jobNumber & "_converted/{jpeg\\ hi-res,jpeg\\ low-res}}/"
end try
Thanks Srefan,
with your help I will enter the scripting world as I can now put into reality and better understand how they work.
I have made your script into an app. and I dragged the app on top of my finder window in the toolbar, I select the folder, than click on the app and voilà !
The only glitch I have is that the app stays open, is there a way to have it closed after it created the subfolders.
Also I could not find a way to include the script in my contextual menu (right click)
Thanks again !!
Hugo
While saving the script you have to uncheck the option stay-open.
To include the script in the contextual menu you need a tool like OnMyCommand
Here’s a more generic solution that can be easily modified to suit anyone’s needs by editing the subfolderList variable. Note that “ArtProofs” for example, has two sublist items: “Proof1” and “Proof2” so they get created within the “ArtProofs” folder, which itself is created within the “ARTWORK” folder.
set subfolderList to {{"REFERENCE", {"refA", "refB"}}, {"ARTWORK", {"ArtAssets", "ArtProofs", {"Proof1", "Proof2"}, "ArtLayout", {"Lay1", "Lay2"}}}}
tell application "Finder"
set JobName to text returned of (display dialog "Please enter Job Name:" default answer "Job_Name")
set Loc to choose folder "Choose Parent Folder Location"
set newfo to (make new folder at Loc with properties {name:JobName}) as alias
end tell
set n to count of items in subfolderList
repeat with i from 1 to n
set eachitem to item i of subfolderList
if class of eachitem is list then
my mysubfolders(newfo, eachitem)
else
tell application "Finder" to make new folder at newfo with properties {name:eachitem}
end if
end repeat
on mysubfolders(parentfolder, mysublist)
set nn to count of items in mysublist
repeat with j from 1 to nn
set eachitem to item j of mysublist
if class of eachitem is list then
set k to j - 1
set nm to item k of mysublist
set subfolder to ((parentfolder as text) & nm) as alias
my mysubfolders(subfolder, eachitem)
else
tell application "Finder"
make new folder at parentfolder with properties {name:eachitem}
end tell
end if
end repeat
end mysubfolders