basically final cut pro will produce a untitled.mov file after it finishes recording. i am copying the name i would like to call the file from an excel sheet. I am having trouble getting finder to select the untitled.mov file renaming it to *****.mov with the data from the clipboard and then copying newly renamed file to a new location.
any help would be greatly appreciated. i’ve been trying to wrap my head around this for a few hours now with no luck
display alert “Press Ok to Start Recording”
– need to add a stop script button to dialog box
tell application “Final Cut Pro”
activate
– have Final cut capture now
tell application “System Events” to key code 8 using shift down
end tell
delay 5
display alert “Press Ok to Stop Recording”
tell application “Final Cut Pro”
activate
– have final cut stop recording
tell application “System Events” to key code 53
end tell
tell application “Microsoft Excel”
activate
– have excel go down one row
tell application “System Events” to key code 125
– have excel copy cell using commmand + C
tell application “System Events” to key code 8 using command down
end tell
set thefolder to “Macintosh Hd:Users:miltonch02:test:”
set copyfolder to “Macintosh Hd:Users:miltonch02:copy:”
tell application “Finder”
if window 1 exists then
set target of window 1 to thefolder
else
reveal thefolder
end if
– select “untitled.mov”
–rename file to contents of clipboard keeping same extension
–copy new file name to “copyfolder” alias
end tell
– loop script back to begining
To rename and duplicate the file use the Finder commands:
set startFolder to "Macintosh Hd:Users:miltonch02:test:"
set doneFolder to "Macintosh Hd:Users:miltonch02:copy:"
tell application "Finder"
if exists file (startFolder & "rename_me.jpg") then
set name of alias (startFolder & "rename_me.jpg") to "RenamedFile.jpg"
--move alias (startFolder & "RenamedFile.jpg") to alias doneFolder with replacing
duplicate alias (startFolder & "RenamedFile.jpg") to alias doneFolder with replacing
end if
end tell
I included the move command commented out in case you want to move instead of copy the file to the new location. I’m not sure about Final Cut, but I know that Excel has a pretty good dictionary that you should be able to do the Excel part using it’s AppleScript commands instead of resorting to scripting key strokes.
yeah , the issue is i need to rename the actuall rename_me.jpg to a new file name. i need to be able to pull the file name from the text that was copied in from the above excel cell which should be in clipboard. and then copy the newly named file to the donefolder. the text from excel wont have the .mov extension though.
To get the string from the clipboard all you need to do is set a variable to the clipboard:
set startFolder to "Macintosh Hd:Users:miltonch02:test:"
set doneFolder to "Macintosh Hd:Users:miltonch02:copy:"
set newFileName to (the clipboard) & ".mov"
tell application "Finder"
if exists file (startFolder & "rename_me.jpg") then
set name of alias (startFolder & "rename_me.jpg") to newFileName
--move alias (startFolder & newFileName) to alias doneFolder with replacing
duplicate alias (startFolder & newFileName) to alias doneFolder with replacing
end if
end tell
I don’t have a lot of experience scripting Excel, but to do the same thing that you are scripting with system events you would do something like this:
set startFolder to "Macintosh Hd:Users:miltonch02:test:"
set doneFolder to "Macintosh Hd:Users:miltonch02:copy:"
tell application "Microsoft Excel"
select range ((ASCII character ((first column index of selection) + 64)) & (first row index of selection) + 1)
set newFileName to (value of selection) & ".mov"
end tell
tell application "Finder"
if exists file (startFolder & "rename_me.mov") then
set name of alias (startFolder & "rename_me. mov") to newFileName
--move alias (startFolder & newFileName) to alias doneFolder with replacing
duplicate alias (startFolder & newFileName) to alias doneFolder with replacing
end if
end tell