AppleScript的将文件复制到一个新的文件夹 [英] Applescript Copy file to a new folder
本文介绍了AppleScript的将文件复制到一个新的文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要创建一个将复制从一个文件夹中指定的文件到新创建的文件夹中的AppleSript。
这些文件需要在AppleScript的编辑器中指定所以是这样的:
启动fileToBeMoved =桌面/测试文件夹1 / Test.doc的
newfoldername =测试文件夹2使newfolder并将其命名为newfoldername
复制fileToBeMoved到newfolder结束
解决方案
一般
告诉应用程序发现者
使在别名新的文件夹的Macintosh HD:用户:用户:桌面:具有属性{名称:测试文件夹2}
拷贝文件的Macintosh HD:用户:用户:桌面:测试文件夹1:Test.doc的文件夹的Macintosh HD:用户:用户:桌面:测试文件夹2
告诉结束
您可以添加变量名重新present POSIX文件和路径。
显然,冒号(:)是文件夹 - 和文件名保留字符。
设置desktopFolder为麦金塔HD /用户/用户/桌面/
设置desktopFdrPosix为desktopFolder的POSIX路径引号形式
设置newFolderName为测试文件夹2
设置destinationFdrPosix为desktopFdrPosix&放引号形式; POSIX文件newFolderName
设置sourceFilename为测试文件夹1 / Test.doc的
设置sourceFnPosix为desktopFdrPosix&放引号形式; POSIX文件sourceFilename告诉应用程序发现者
使新的文件夹的别名desktopFdrPosix具有属性{名称:newFolderName}
拷贝文件sourceFnPosix到文件夹destinationFdrPosix
告诉结束
您可能还需要增加,如果目标文件夹已经存在错误检查。
I need to create an AppleSript that will copy specified files from one folder to a newly created folder.
These files need to be specified in the AppleScript editor so something like:
start
fileToBeMoved = "Desktop/Test Folder 1/test.doc"
newfoldername = "Test Folder 2"
make newfolder and name it 'newfoldername'
copy 'fileToBeMoved' to 'newfolder'
end
解决方案
Generally:
tell application "Finder"
make new folder at alias "Macintosh HD:Users:user:Desktop:" with properties {name:"Test Folder 2"}
copy file "Macintosh HD:Users:user:Desktop:Test Folder 1:test.doc" to folder "Macintosh HD:Users:user:Desktop:Test Folder 2"
end tell
You can add variable names that represent POSIX files and paths.
Obviously the colon character (:) is a reserved character for folder- and filenames.
set desktopFolder to "Macintosh HD/Users/user/Desktop/"
set desktopFdrPosix to quoted form of POSIX path of desktopFolder
set newFolderName to "Test Folder 2"
set destinationFdrPosix to quoted form of desktopFdrPosix & POSIX file newFolderName
set sourceFilename to "Test Folder 1/test.doc"
set sourceFnPosix to quoted form of desktopFdrPosix & POSIX file sourceFilename
tell application "Finder"
make new folder at alias desktopFdrPosix with properties {name:newFolderName}
copy file sourceFnPosix to folder destinationFdrPosix
end tell
You may also want to add error checking if the destination folder already exists.
这篇关于AppleScript的将文件复制到一个新的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文