Applescript重命名文件夹中的文件
这里还是个新手 因此,我试图重命名文件夹中的文件Applescript重命名文件夹中的文件,applescript,Applescript,这里还是个新手 因此,我试图重命名文件夹中的文件 set newfoldername to DT & "-" & JobName & " - " & Wedding --Adds Date, Couples name and event type to make directory name 这里有更多代码 set destFolder to loc & newfoldername & ":Final Delivery:DVD:" tell ap
set newfoldername to DT & "-" & JobName & " - " & Wedding --Adds Date, Couples name and event type to make directory name
这里有更多代码
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出现错误:无法将文件“DVD\u template.dspproj”设置为“newfoldername.dspproj\”,文件“DVD\u template.dspproj”中的编号-10006
我尝试了各种方法,上面设置了扩展名“newfoldername”和不设置扩展名“newfoldername”,并使用用户输入的名称创建了一个文件夹
是我太傻了还是我完全错过了什么
编辑
您正试图重命名桌面上显然不存在的文件“DVD_template.dspproj”。桌面文件夹是查找器的根文件夹 Finder的
duplicate
命令返回复制的文件,因此它非常简单
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.
我可以(出于某些奇怪的原因)让它重命名文件,但要向后重命名,这样它将重命名模板文件名,而不是使用新文件夹名“newfoldername”并重命名文件“DVD_template.dspproj”。该名称应该是前面声明的变量,即“newnamefolder”,我已经在上面添加了所有代码。在上面的示例中,确切的预期文件名(最后一个路径组件)是什么?将newfoldername设置为DT&“-”&JobName&“-”&widding这是用户(我)输入的信息,应该是YYYY/MM/DD-name-EVENT.dspproj这似乎已经完成了,今晚晚些时候我会做更多的测试。
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.