2013-02-28 103 views
0

嗨,我试图创建一个AppleScript做到以下几点:AppleScript的移动2种文件到不同的文件夹

在本周有几个JPG和EPS我的硬盘上的文件。我有两个文件夹:矢量和图像。 几天后,我得到几十个这种混合文件,我必须手动选择并移动到其各自的文件夹。

如何将.eps移动到VECTOR文件夹和jpg到IMAGES文件夹。 我不知道什么applescripting,所以我复制其他脚本的部分,并把这个在一起:

上运行{输入,参数} - 复制

if theExtension is "eps" then 
    set destination to ~/user/Desktop/VECTO 
end if 
    tell application "Finder" 
     move anItem to destination 
if theExtension is "jpg" then 
    set destination to ~/user/Desktop/IMAGO 
end if 
    tell application "Finder" 
     move anItem to destination 

运行结束

中当然这是错误的,但希望有人能帮助我把这个直线 Thnx!

回答

1

我假设你将这个问题的表达方式合并到Automator工作流程中。

on run {input, parameters} -- copy 
    repeat with aFile in input 
     tell application "Finder" 
      if name extension of aFile is "eps" then 
       move aFile to folder ((path to desktop as text) & "VECTO") 
      else if name extension of aFile is "jpg" then 
       move aFile to folder ((path to desktop as text) & "IMAGO") 
      end if 
     end tell 
    end repeat 
end run 

如果不是你可以使用:

set myFiles to (choose file with multiple selections allowed) 
repeat with aFile in myFiles 
    tell application "Finder" 
     if name extension of aFile is "eps" then 
      move aFile to folder ((path to desktop as text) & "VECTO") 
     else if name extension of aFile is "jpg" then 
      move aFile to folder ((path to desktop as text) & "IMAGO") 
     end if 
    end tell 
end repeat 
+0

没错,我会加入到这个自动机。让我试试这个...... – AlexSanchez 2013-02-28 21:55:44

+0

第一个作品完美!现在还有第二个问题,我有一个NAS驱动器,其中有一个用于备份的同名文件夹。我怎样才能让这个脚本直接将文件复制到NAS驱动器? – AlexSanchez 2013-02-28 22:04:13

相关问题