I’m new to AppleScript (and scripting in genera). I searched the forum and tried what I could, but now I’m stumped and would love some help.
I’m recording video on my Mac using a program that stores video in one type of file format, then I need to use Compressor to convert it to another format and store it in a separate folder, but with the same directory structure. Here is what I’ve done so far:
- Attach a Folder Action Script to the main video storage folder that attaches a DIFFERENT script automatically to any folder created under that folder. I call this one “add script to subfolder.scpt”. It works perfectly, and here it is:
property ScriptName : "SendVideoToDroplet.scpt"
property ScriptPath : ":Library:Scripts:Folder Action Scripts:" & ScriptName
on adding folder items to thisfolder after receiving theseitems
tell application "Finder"
repeat with thisItem in theseitems
if (class of item thisItem is folder) then
tell application "System Events"
attach action to thisItem as alias using ScriptPath
end tell
end if
end repeat
end tell
end adding folder items to
- I have created a “Droplet.app” file in Compressor that will do the exact video conversion I need, in the background. I’ve also created an applescript, referenced in the prior script, that sends any new items in that folder, to the Droplet. The Droplet can only output files to a single, specified folder. However, I can add anything I want to the output filename, such as “-converted”. This script is as follows:
on adding folder items to thisFolder after receiving theItems
-- this is the standard intro for a folder action
repeat with f in theItems
-- wait for the item to be all there
set Was to 0
set isNow to 1
repeat while isNow ≠Was
-- the basic idea is that the script loops until the file size is the same for more than 30 seconds. That means the file has finished copying.
set Was to size of (info for f)
-- this section is getting the file size of the video
delay 30
set isNow to size of (info for f)
-- this section is sampling the file size 30 seconds later
end repeat
tell application "Finder"
open theItems using application file "Droplet.app" of folder "Desktop" of folder "division" of folder "Users" of startup disk
end tell
end repeat -- get next item f in thisFolder
end adding folder items to
- Here’s where I need help… I want to move the output files from the droplet, to a similar but separate directory structure. For example, right now the original movies are in: Playback Storage:QTAKE Projects:Day 1: - I want the output files from Compressor to be in: Playback Storage:Converted Projects: Day 1: - where the folder “Day 1” would be created by a Folder Action Script to match the directory structure of the original file.
My thought is to set the compressor droplet to create an output file called “OriginalFileName-converted.mp4” - where we added “-converted”. Then, add to the “SendVideoToDroplet.scpt” Folder Action Script, some script where “if the filename contains -converted, then create a folder with the same name/structure as this one, but under the Converted Projects folder, and move the file there. Otherwise, continue the script - which sends the file to the Droplet”.
However, whatever I try seems to fail at that part. I would really appreciate any help that could be given to me.
Thanks in advance…
Model: Mac Pro - 12 Core, 24gb RAM
AppleScript: Latest
Browser: Safari 533.21.1
Operating System: Mac OS X (10.7)