2013-02-28 102 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

相關問題