2017-02-20 3 views
0

Еще Noob/новичок здесьApplescript переименовать файл в папку

Так что я пытаюсь переименовать файл в папке

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

MORE КОД ЗДЕСЬ

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 

Но Я только хочу получить сообщение

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

Я пробовал разные способы: с добавлением и без расширения «newfoldername» установлено выше и создает папку с именем пользователя как имя

Я просто глупо или что-то пропустил.

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 

ответ

0

Вы пытаетесь переименовать файл «DVD_template.dspproj» на рабочем столе, который, очевидно, не существует. Папка рабочего стола - это корень папка Finder.

duplicate командование Finder возвращает дубликат файла, так что это просто

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 

Если вы хотите переименовать файл newfoldername вы должны скопировать и добавить расширение файла.

PS: Вместо расчета папке шаблона 5 раз рекомендую написать

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. 
+0

я могу (по какой-то причине) получить его, чтобы переименовать файл, но в обратном направлении, так что будет переименовать имя файла шаблона, а не взяв новое имя папки «newfoldername» и переименовав файл «DVD_Template.dspproj» –

+0

Имя должно быть из объявленной ранее переменной, на которой находится «newnamefolder», я добавил весь код выше –

+0

. Какова точная ожидаемая ** имя файла ** (последний компонент пути) в примере выше? – vadian

Смежные вопросы