Applescript要删除文件,该名称不包含“\s”
我是一个完全熟悉applescript的新手,所以说。。 我要做的是删除文件夹中的特定文件。例如: 我有以下文件: C9361WL_1.jpg C9361WL_1.jpg C9361WL_2.jpg C9361WL_3.jpg C9361WL_4.jpg C9361WL_1_.jpg C9361WL_2_.jpg C9361WL_3_.jpg C9361WL_4_.jpg 我想删除名称文件中不包含的文件 提前感谢您的帮助 我在Automator中编写的代码是:Applescript要删除文件,该名称不包含“\s”,applescript,automator,Applescript,Automator,我是一个完全熟悉applescript的新手,所以说。。 我要做的是删除文件夹中的特定文件。例如: 我有以下文件: C9361WL_1.jpg C9361WL_1.jpg C9361WL_2.jpg C9361WL_3.jpg C9361WL_4.jpg C9361WL_1_.jpg C9361WL_2_.jpg C9361WL_3_.jpg C9361WL_4_.jpg 我想删除名称文件中不包含的文件 提前感谢您的帮助 我在Automator中编写的代码是: on run {input, pa
on run {input, parameters}
repeat with this_file in input
if this_file does not contain "_s" then
delete this_file
end if
end repeat
return input
end run
这个脚本仍然不走运,我已经做了一些修改
on run {input, parameters}
repeat with this_file in input
set thePath to POSIX file of this_file as alias
set delFiles to (every file of thePath whose name does not contain "_s")
tell application "Finder"
move files of delFiles to "/Users/dyohanan/Desktop/"
end tell
end repeat
return input
end run
差不多,但是您需要告诉查找程序执行删除操作,并且您需要检查文件名
on run {input, parameters}
repeat with this_file in input
tell application "Finder"
if name of this_file does not contain "_s" then
delete this_file
end if
end tell
end repeat
return input
end run
嗨,瓦迪安,谢谢你的帮助。我照你说的做了,现在我收到一条错误消息,告诉我:语法错误:无法将项1的名称转换为类型引用脚本假定输入是一个别名说明符列表。你是对的,当我仅使用一个项而不是列表进行测试时,出现了错误。但是现在我没有收到错误,但是脚本没有删除文件。