Applescript如何制作文件列表并移动具有特定名称的文件

Applescript how to make file list and move files with certain names

我想制作一个脚本,它接受一个名称列表,并将与该列表具有相似名称的某些文件移动到另一个文件夹中。

为了分解它,我有一个包含几个文件的文件夹 "appleClient2016.pdf"、"fruitClient2016.pdf"、"pearClient2016.pdf"

现在我有 "appleSept"、"pearSept" 的列表 我想将我的列表移到另一个文件夹中。

我需要一个识别 appleSept 的脚本,appleClient2016.rtf 字符串中都有 apple 并将 pdf 移动到另一个文件夹中。而且它只能移动pdf文件。

我对 applescript 很陌生,但这是我的尝试

set listOfFruits to {"appleSept", "pearSept"}

 tell application "Finder"

if folder "moveTest1" contains listOfFruits then
    move (every file of folder "moveTest1" whose name is listOfFruits) to folder "moveTest2"
end if

 end tell

我知道我这里有一些语法错误,但我想你明白我要做什么。 任何建议将不胜感激。

谢谢!

考虑关于 listOfFruits 的两件事,它是 字符串 .

的列表
  1. 文件夹从不包含字符串列表,它包含文件或文件夹列表(包含 listOfFruits)。
  2. 一个文件从来没有一个名称,它是一个字符串列表(其名称是 listOfFruits)。

基本上不需要用if子句检查1.

要检查名称是否在 您必须编写 is in 而不是 is.
的字符串列表 理解语法 is in:表达式 a is in {a, b, c}{a, b, c} contains a

相同
    set listOfFruits to {"appleSept", "pearSept"}

    tell application "Finder"
        move (every file of folder "moveTest1" whose name is in listOfFruits) to folder "moveTest2"
    end tell