Rename a file in a Video Editing Workflow script

Hi, I’m new to AppleScript and am trying to setup a script that automates my video editing workflow.
The script essentially creates a directory structure after prompting the user for name variables and a save location. As part of this script, a template Final Cut Pro X Library file (think of this as the project file) is copied from the users Movies folder to the newly created structure. The issue I’m having is renaming this file. The new name should read as "variable 1 - variable 2.fcpbundle

Note, that a .fcpbundle file is technically a directory so I don’t know if this throws a wrench in my plans or not.

Anyways, here’s the AppleScript I’ve written so far:

property src : POSIX file "/Users/brodbb/Movies/JobTemplate-DoNotDelete.fcpbundle" as alias

tell application "Finder"
	set mediaNumber to text returned of (display dialog "Enter the Media Number" default answer "xxxxx") --stores media number as a variable
	set jobName to text returned of (display dialog "Enter the Project/Job Name" default answer "") --stores job name as a variable
	set loc to choose folder "Choose Where to Save This Job" --chooses a location to save the job folder to
	set NewJobFolder to (mediaNumber) & " - " & (jobName) --combines the mediaNumber & jobName variables into the "9999 - Job" format
	set JobFolder to make new folder at loc with properties {name:NewJobFolder} --places the job folder at the selected location
	set ASSET to make new folder at JobFolder with properties {name:"ASSET"} --targets the new job folder & creates "ASSET" subfolder
	set RAW to make new folder at JobFolder with properties {name:"RAW"} --targets the new job folder & creates "RAW" subfolder
	set MASTER to make new folder at JobFolder with properties {name:"MASTER"} --targets the new job folder & creates "MASTER" subfolder
	set fcpxMEDIA to "FCPX MEDIA" & " " & (mediaNumber) --stores "FCPX MEDIA mediaNumber" as a variable
	make new folder at RAW with properties {name:fcpxMEDIA} --targets the "RAW" folder & creates "FCPX MEDIA xxxxx" subfolder
	make new folder at MASTER with properties {name:"ProRes"} --targets the "MASTER" folder & creates "ProRes" subfolder
	make new folder at MASTER with properties {name:"YouTube"} --targets the "MASTER" folder & creates "YouTube" subfolder
	make new folder at MASTER with properties {name:"MP4"} --targets the "MASTER" folder & creates "MP4" subfolder
	set dest to ASSET
	duplicate src to dest
	set the name of folder "JobTemplate-DoNotDelete.fcpbundle" to (mediaNumber) & " - " & (jobName) & ".fcpbundle"
end tell

When running this code, it makes my directory structure but fails to rename the .fcpbundle file (which is the last line before the end tell). If the mediaNumber variable was 9999 and the jobName variable was My Job the error that Apple Script would read out is “Finder got an error: Can’t set folder “JobTemplate-DoNotDelete.fcpbundle” to “9999 - My Job.fcpbundle”.”

So essentially I need help transforming that last line before the end tell into something that works.
Like I say, I’m totally new to AppleScript so hopefully I’ve laid out the issue clearly. I’m about 100 pages into Sal Sogohian’s AppleScript 1-2-3 book and a number of web searches to get my script to this point so I’ll probably have to look up the jargon in most of the responses…regardless, I appreciate any and all help here. Thanks! - Ben

1 Like

You seem to only be saying “set the name of folder xxxx”. I think you need the full hierarchy/path, e.g.

set the name of folder "Macintosh HD:etc:etc:JonTemplate" to yadda yadda

or

set the name of folder "JobTemplate-DoNotDelete.fcpbundle" of folder "parent folder" of folder "parent folder" to yadda yadda.