我正在尝试将文件从1个文件夹移动到某个文件夹(如果它们具有特定名称)。 listOfFiles是要移动的文件。
我收到的错误无法使{\" file1.rtf \",\" file2.rtf \",\" file3。 rtf \"}进入类型整数
我还没有条件检查这个名字。首先尝试移动文件。
set listOfFiles to {"file1.rtf", "file2.rtf","file3.rtf"}
tell application "Finder"
set sourceFolder to ((path to desktop) & "moveTest1") as string as alias
set goFolder to ((path to desktop) & "moveTest2") as string as alias
set goFiles to the name of every file of sourceFolder
repeat with i from 1 to the count of goFiles
if goFiles = listOfFiles then
move file goFiles to folder goFolder
end if
end repeat
end tell
谢谢!
答案 0 :(得分:0)
主要问题是您无法使用单个goFiles
说明符指定字符串列表(file
)。
假设您要将文件夹moveTest1
中的所有文件复制到文件名为moveTest2
的文件夹listOfFiles
,您可以在一行中过滤这些文件:
set goFiles to every file of sourceFolder whose name is in listOfFiles
由于桌面文件夹是Finder
的根文件夹,因此您无需明确指定桌面文件夹。
set listOfFiles to {"file1.rtf", "file2.rtf", "file3.rtf"}
tell application "Finder"
set sourceFolder to folder "moveTest1"
set goFolder to folder "moveTest2"
set goFiles to every file of sourceFolder whose name is in listOfFiles
move goFiles to goFolder
end tell
实际上,您可以在一行中编写move
操作
tell application "Finder" to move (every file of folder "moveTest1" whose name is in listOfFiles) to folder "moveTest2"