1
votes

Still a Noob / novice here

So I am trying to rename a file within a folder

set newfoldername to DT & "-" & JobName & " - " & Wedding --Adds Date, Couples name and event type to make directory name

MORE CODE HERE

set destFolder to loc & newfoldername & ":Final Delivery:DVD:"
tell application "Finder"
   duplicate file sourcedvdtemp to folder destFolder
   set the name of file "DVD_template.dspproj" to newfoldername
end tell

But I just get an error

"error "Finder got an error: Can’t set file \"DVD_template.dspproj\" to \"newfoldername.dspproj\"." number -10006 from file "DVD_template.dspproj""

I have tried various ways, with and without the extension "newfoldername" is set above and creates a folder with the users input as a name

Am I just being stupid or have I missed something completely.

EDIT

tell application "Finder" to set frontmost to true
set DT to text returned of (display dialog "Please enter the wedding date" default answer "YYYY/MM/DD") --Asks for date of wedding
set JobName to text returned of (display dialog "Please enter the couples name" default answer "Bride & Groom + Surname") --Asks for couples name
set Wedding to text returned of (display dialog "Please enter the type of day" default answer "Wedding") --Asks for type of day, Wedding, Party, etc
--Creates directory with info from above
set loc to (choose folder "Please choose where you would like to save the files") as text --Loc = Location of where directory will be placed
set newfoldername to DT & "-" & JobName & " - " & Wedding --Adds Date, Couples name and event type to make directory name
set folderStructure to "/{Audio/{Music,RAW\\ Audio\\ Cards},Documents,Exports,FCPX\\ Library,Film\\ Poster,Final\\ Delivery/{DVD,USB,WEB},Images/{Graphics,Stills},RAW\\ Cards/{C100-1,C100-2,7D,100D},XML}"
do shell script "mkdir -p " & quoted form of POSIX path of (loc & newfoldername) & folderStructure

set sourcedvdtemp to (path to movies folder as text) & "## - WeddingTemplate - ##:DVD_template.dspproj" --Gets file DVD_template
set sourceusbtemp to (path to movies folder as text) & "## - WeddingTemplate - ##:USB_template.zip" --Gets file USB_template
set sourcewebtemp to (path to movies folder as text) & "## - WeddingTemplate - ##:WEB_template.zip" --Gets file WEB_template
set sourcefcpxtemp to (path to movies folder as text) & "## - WeddingTemplate - ##:FCPX_template.fcpbundle" --Gets file FCPX_template
set sourcefilmpostemp to (path to movies folder as text) & "## - WeddingTemplate - ##:FILM_POSTER_Template.psd" --Gets file FILM_POSTER_template

set destFolder to loc & newfoldername & ":Final Delivery:DVD:"
tell application "Finder"
    duplicate file sourcedvdtemp to folder destFolder
    set the name of file "DVD_template.dspproj" to newfoldername
end tell

set destFolder to loc & newfoldername & ":FCPX Library:"
tell application "Finder"
    duplicate file sourcefcpxtemp to folder destFolder
    set the name of file "FCPX_template.fcpbundle" to newfoldername
end tell

set destFolder to loc & newfoldername & ":Film Poster:"
tell application "Finder"
    duplicate file sourcefilmpostemp to folder destFolder
    set the name of file "FILM_POSTER_Template.psd" to newfoldername
end tell
1

1 Answers

1
votes

You are trying to rename a file "DVD_template.dspproj" on desktop which obviously does not exist. The desktop folder is the root folder of the Finder.

The duplicate command of the Finder returns the duplicated file so it's simply

tell application "Finder"
   set fileExtension to name extension of file sourcedvdtemp
   set duplicatedFile to duplicate file sourcedvdtemp to folder destFolder
   set name of duplicatedFile to newfoldername & "." & fileExtension
end tell

If you want to rename the file to newfoldername you have to copy and add the file extension.

PS: Instead of calculating the template folder 5 times I recommend to write

set weddingTemplateFolder to (path to movies folder as text) & "## - WeddingTemplate - ##:"
set sourcedvdtemp to weddingTemplateFolder & "DVD_template.dspproj" --Gets file DVD_template
set sourceusbtemp to weddingTemplateFolder & "USB_template.zip" --Gets file USB_template 
... etc.