I’ve had some amazing help with some workflow scripts courtesy James Nierodzik right her on the forums. I’ve been harassing him quite a bit the last week or so and I think I need to pick on some other people for a change.
He’s helped build a script that scans the contents of a job folder, which contains a collection of various elements. It looks for any files (elements) whose creation date and mod date are the same. Not all elements are used for each job. If the dates are the same that element is purged from the job folder along with any resulting empty folders. The result is a clean job folder free of the extra bloat.
Now I’ve been tasked with grabbing an element from OUTSIDE the job folder and moving into the cleaned-up, ready-to-archive folder. They use iMovie '08 to create a slideshow with customized transitions, etc, followed by dropping the iMovie project into an iDVD template. The problem is that iMovie project does not get included with the archive as iMovie '08 stores its projects in its own movies (~/Movies/iMovie Projects) folder.
As an aside, typically each user work on 10-12 jobs each day. As times goes on, iMovie '08 take longer and longer to open as the iMovie Projects folder never gets cleared out and the user has this lengthy list in the Project Library pane of iMovie '08 – slowing them down.
Is it feasible to have the clean up script grab the relevant iMovie project and move it to a folder within the clean-up, ready-to-archive folder? Currently all the files contain a prefix matching the job name, i.e. 000_Lastname. If the iMovie project was named with that prefix, could it select it and move it?
Here is the relevant element, on cleanUp, of the clean up script (again thanks to James Nierodzik):
on cleanUp(theJob)
tell application "Finder"
try
cleanFolder as alias
on error
display alert "alerting phrase" message "descriptive message" buttons {"Cancel", "Select Folder."} cancel button 1 as warning
set cleanFolder to (choose folder with prompt "Please select folder") as Unicode text
end try
set choice to ""
try
set jobName to name of theJob
(cleanFolder & jobName) as alias
set choice to button returned of (display alert "The order \"" & jobName & "\" already exits in folder" message "What should I do?" buttons {"Replace", "Skip"})
end try
if choice is in {"", "Replace"} then
try
set theFiles to every file of entire contents of theJob as alias list
on error
set theFiles to every file of entire contents of theJob as alias as list
end try
repeat with aFile in theFiles
if modification date of aFile is equal to creation date of aFile then
do shell script "rm " & quoted form of (POSIX path of aFile)
end if
end repeat
try
set theFolders to every folder of entire contents of theJob as alias list
on error
set theFolders to every folder of entire contents of theJob as alias as list
end try
repeat with aFolder in theFolders
try
set theFiles to every file of entire contents of aFolder
on error
try
do shell script "rm -r " & quoted form of (POSIX path of aFolder)
end try
end try
end repeat
move theJob to (cleanFolder as alias) with replacing
end if
end tell
end cleanUp