I’m sure the answer is in these forums but I may not be using the right search terms. So far I have this script which works on a single folder. It prompts you to select a folder , creates a series of sub folders within that, then moves any of the files that were in the selected folder into one of the newly created sub folders.
tell application "Finder"
--choose which folder to run this on
set currentFolder to (choose folder)
-- make new folders
make new folder at currentFolder with properties {name:"01 FOC"}
make new folder at currentFolder with properties {name:"02 Clinical Notes"}
make new folder at currentFolder with properties {name:"03 Laboratory"}
make new folder at currentFolder with properties {name:"03 Imaging"}
make new folder at currentFolder with properties {name:"04 Imaging"}
make new folder at currentFolder with properties {name:"05 Consultations"}
make new folder at currentFolder with properties {name:"06 Legal-Insurance"}
set oldChart to make new folder at currentFolder with properties {name:"07 Old Chart"}
-- move files to Old Chart folder
set folderContents to every file of the folder currentFolder
repeat with currentFile in folderContents
move currentFile to oldChart
end repeat
end tell
Now I need to take this up one level. I want to select one folder and have the script produce the same effect on the 300 folders within it (go into each patient folder, create subfolders, and move any documents that were in the patient folder to the newly created ‘07 Old Chart’ folder.
Here is what I’ve tried so far:
--choose which folder to run this on
set mainFolder to (choose folder)
--create a list of all the folders within
tell application "Finder"
set patientFolderList to every folder of mainFolder
end tell
--loop through every folder
repeat with currentFolder in patientFolderList
-- make new folders
tell application "Finder"
make new folder at currentFolder with properties {name:"01 FOC"}
make new folder at currentFolder with properties {name:"02 Clinical Notes"}
make new folder at currentFolder with properties {name:"03 Laboratory"}
make new folder at currentFolder with properties {name:"03 Imaging"}
make new folder at currentFolder with properties {name:"04 Imaging"}
make new folder at currentFolder with properties {name:"05 Consultations"}
make new folder at currentFolder with properties {name:"06 Legal-Insurance"}
set oldChart to make new folder at currentFolder with properties {name:"07 Old Chart"}
-- move files to Old Chart folder
set folderContents to every file of the folder currentFolder
repeat with currentFile in folderContents
move currentFile to oldChart
end repeat
end tell
end repeat
The script fails when I try to create the list of files in the currentFolder to move. If I remove that part of the script it does work. It goes through all the patient folders and creates sub folders in each. Any suggestions.