Creating list of folders from filenames with files organized in subfolders within
Hi all. This is my first post in the Apple Support Community and I really hope that someone can help me as I'm using apple script for the first time.
I have a list of hundreds of items that are each .jpg, .cr2, or .mov. Certain filenames have multiple extensions, ex: Q95A7170.CR2 & Q95A7170.jpg.
I'm looking for an applescript or automator action that will allow me to create a folder out of each filename with 5 subfolders in it
I need the subfolders to be called:
AUDIO
COLOR
METADATA
PICTURE
PROXY
In this instance I need all the .mov, .cr2, and .jpgs to be routed to the PICTURE folder. In later instances I'll need to route .mxf to PICTURE AND .xml .sif & .thm to METADATA.
So for example I have a list of that looks like this
and I want a script that will make it look like this (i did all of this manually: creating the folders, renaming them, and putting the specific files into the picture folder)
(not nearly a fraction of the list -- there are hundreds and hundreds of files)
I've been researching applescripts for hours but the only script that i could make work and was very useful was this one to create the folders out of the names of the files:
tell application "Finder"
set selected to selection
set current_folder to item 1 of selected
set mlist to every file of current_folder
repeat with this_file in mlist
set cur_ext to name extension of this_file
set new_name to text 1 thru -((length of cur_ext) + 2) of (name of this_file as text)
set new_folder to makenewfolderwith properties {name:new_name} atcurrent_folder
movethis_filetonew_folder
end repeat
end tell
Even with this script I had to manually copy all of the duplicate file named .jpgs out of the folder before it would properly run.
Also I've found these scripts but I'm not sure what information to change. Like I said, I don't know much about code at all and I'm finding more research about it is just digging me deeper in a hole that I'm not entirely ready for.
Here are the other two scripts that CLAIM they can do what I'm looking for, but I haven't gotten them to work.
1.
set pathToFolderOfTTUFiles to (path to the desktop as text) & "TTU:"
tell application "Finder"
set theFiles to every item of folder pathToFolderOfTTUFiles whose name extension is not "csv" and kind is not "Folder"
repeat with theFile in theFiles
set lengthOfExtension to (length of (theFile's name extension as text)) + 1
set fileNameWithoutExtension to text 1 through -(lengthOfExtension + 1) of (theFile's name as text)
set theFolder to make new folder at folder pathToFolderOfTTUFiles with properties {name:fileNameWithoutExtension}
set theContentFolder to make new folder at theFolder with properties {name:"content"}
make new folder at theContentFolder with properties {name:"archive"}
set theContentDisplayFolder to make new folder at theContentFolder with properties {name:"display"}
set theMetadataFolder to make new folder at theFolder with properties {name:"metadata"}
make new folder at theMetadataFolder with properties {name:"archive"}
set theMetadataDisplayFolder to make new folder at theMetadataFolder with properties {name:"display"}
move theFile to theContentDisplayFolder
set pathToCSV to pathToFolderOfTTUFiles & fileNameWithoutExtension & ".csv"
if exists pathToCSV then move pathToCSV to theMetadataDisplayFolder
end repeat
end tell
2.
set myFolder to "FOLDERPATH"
tell application "Finder" to set myFiles to folder myFolder's files as alias list
repeat with aFile in myFiles
tell application "System Events" to set {fileName, fileExt} to {name, name extension} of aFile
set baseName to text 1 thru ((get offset of "." & fileExt in fileName) - 1) of fileName
do shell script "mkdir -p " & (quoted form of (POSIX path of myFolder)) & "/" & baseName & "/{\"content\",\"metadata\"}/{\"display\",\"archive\"}"
tell application "System Events"
if fileExt is "pdf" then move aFile to (myFolder & ":" & baseName & ":content:display" as text)
if fileExt is "csv" then move aFile to (myFolder & ":" & baseName & ":metadata:display" as text)
end tell
end repeat
(the .pdf, .csv extensions are examples from the person who posted that discussion.)
I tried using both of these codes but to no avail.
Overall, this process is incredibly time-consuming and this is the first time I am using apple script so I know almost nothing about code.
Also I don't know if this changes anything, but all of these files are on an external and I'm trying to save them back on this external.
PLEASE HELP! I am a night assistant editor doing very tedious work at 3:00 AM or later and anything that would expedite this process would be so unbelievably appreciated. Please, someone who's more experience with code and who's smarter than I am on this topic, help me! I know there must be a way to automate this process!
Please and so many thank yous! Really, this code would save me 40+ hours of eye-tiring work.
Shelby
Mac Pro, Mac OS X (10.6.8), 2 x 2.26 GHz Quad-Core Intel Xeon