2017-03-07 1 views
0

私は完全にAppleScriptの初心者ですので、そうです。 私がしたいのは、フォルダ内の特定のファイルを削除することです。たとえば:AppleScriptでファイルを削除すると、その名前に "_s"が含まれていません

  • C9361WL_1.jpg
  • C9361WL_1.jpg
  • C9361WL_2.jpg
  • C9361WL_3.jpg
  • C9361WL_4.jpg
  • C9361WL_1_s:

    私はこのファイルを持っています。 jpg

  • C9361WL_2_s.jpg
  • C9361WL_3_s.jpg
  • C9361WL_4_s.jpg

私は名前のファイル内の "_s" が含まれていないファイルを削除します。

ご協力いただきありがとうございます。

私はAutomatorの中で書いたコードは次のとおりです。

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 

答えて

1

を運はしないが、あなたは実行するFinderを指示する必要があります削除操作を行い、ファイルのという名前のを確認する必要があります。

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 
+0

こんにちは、あなたにお世話になります。私はあなたが私に言ったことをして、今私に言っているエラーメッセージを受け取りました: 構文エラー: "タイプ1の名前をタイプリファレンスにすることはできません" – Dan

+0

スクリプトは、 'input'がエイリアス指定子のリストであると仮定します。 – vadian

+0

あなたは正しいと思いますが、リストの代わりに1つの項目でテストしたときにエラーが発生しました。 しかし、私はエラーを受け取りませんが、スクリプトはファイルを削除しません。 – Dan

関連する問題