これまでリンゴスクリプトに触れたことはありません。ちょうど1つの小さなスクリプトが必要ですが、どこから起動するのかわかりません。私はフォルダ内のRARファイルを置くときApplescript Noob、unrar .rarファイルとそのファイルを移動する
私がやりたいすべてのフォルダアクションのスクリプトを実行します。..
は基本的に実行します。 unrarし、別のフォルダへのムービーファイルの場合にのみ、ファイルを移動する必要がありますか?
これは可能ですか?
リー
これまでリンゴスクリプトに触れたことはありません。ちょうど1つの小さなスクリプトが必要ですが、どこから起動するのかわかりません。私はフォルダ内のRARファイルを置くときApplescript Noob、unrar .rarファイルとそのファイルを移動する
私がやりたいすべてのフォルダアクションのスクリプトを実行します。..
は基本的に実行します。 unrarし、別のフォルダへのムービーファイルの場合にのみ、ファイルを移動する必要がありますか?
これは可能ですか?
リー
おかげでRAR Expander
をダウンロードし、アプリケーションフォルダにアプリをドロップ: http://rarexpander.sourceforge.net/Downloads.html
は、先に進む前に一度RAR Expander
を開くことを確認してください。
は今、次のAppleScriptを実行します。スクリプトによって
property extensionList : {"mp4", "flv"}
tell application "Finder"
set the sourceFolder to choose folder with prompt "Select Input Folder"
set the outputFolder to choose folder with prompt "Select Output Folder"
set inputFiles to every file of the sourceFolder whose name extension is "rar"
repeat with i from 1 to the count of inputFiles
set theArchive to POSIX path of ((item i of inputFiles) as string)
tell application "RAR Expander"
expand theArchive to POSIX path of outputFolder
end tell
end repeat
set extractedFiles to every file of the outputFolder
repeat with i from 1 to the count of extractedFiles
if (the name extension of the (item i of extractedFiles) is not in the extensionList) then
do shell script "rm -rf " & quoted form of (POSIX path of ((item i of extractedFiles) as string))
end if
end repeat
end tell
ワークフローは次のように説明し
Archive_Containing_FLV_File.rar
Archive_Containing_MP4_File.rar
Archive_Containing_PDF_File.rar
スクリプトを実行した後、出力フォルダのみが含まれています:
はThe_Extracted_FLV_File.flv
The_Extracted_MP4_File.mp4
PDFファイル(The_Extracted_PDF_File.pdf
)が自動的に
は、入力フォルダには、以下のファイルが含まれていますスクリプトによって削除されました。
注:上記のスクリプトはすばやく作成され、最適化することができます。
私はこの質問があなたにとって良い出発点になると思います:http://stackoverflow.com/questions/3896175/applescript-processing-files-in-folders-recursively – Asmus