我正在使用AppleScript重命名文件并将其移动到文件夹。这是使用语音命令执行的。它不会将文件移动到文件夹,而是按Enter键,将文件重命名为“ myFile”,然后再次按Enter键。
但是,如果我第二次执行此操作,或者如果文件名为“ myFile”,它将起作用。我认为用于移动文件的代码不知道,或者文件名未更新。我不知道该如何解决。AppleScript不是我的事。
tell application "System Events"
key code 36
keystroke "myFile"
key code 36
end tell
tell application "Finder"
move POSIX file "/Users/joe/Desktop/myFile.csv" to POSIX file "/Users/joe/Desktop/TestFolder" with replacing
end tell
选择文件后,尝试以下操作:
tell application "Finder"
set itemlist to the selection
set theFile to (item 1 of itemlist) as alias
set name of theFile to "myFile.csv"
move POSIX file "/Users/joe/Desktop/myFile.csv" to POSIX file "/Users/joe/Desktop/TestFolder" with replacing
end tell
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句