続・ダウンロードファイルを日付ごとにフォルダを作成し自動で振り分けるAppleスクリプト
ファイルを日付ごとのフォルダを作成し自動で振り分けるAppleスクリプトですが、ファイルがダウンロードされるまでに作られる.partファイルが先に移動されて、ダウンロードが失敗しましたので、if文を追加して.partファイルを除外する仕様に変更しました。
1 2 3 4 5 6 7 8 |
if not (name contains ".part") then //追加した記述 if not (exists folder todayDate of thisFolder) then make new folder at thisFolder with properties {name:todayDate} end if try move file curItem to folder todayDate of thisFolder end try end if //追加した記述 |
全体のソース
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
on adding folder items to thisFolder after receiving theseItems tell application "Finder" set fileList to every file of thisFolder as list set folderList to every folder of thisFolder as list repeat with i from 1 to number of items in fileList set curItem to item i of fileList as alias set curItemPath to (do shell script "stat -f \"%B\" " & (quoted form of (POSIX path of curItem))) set todayDate to do shell script "date +%Y-%m-%d" if not (name contains ".part") then if not (exists folder todayDate of thisFolder) then make new folder at thisFolder with properties {name:todayDate} end if try move file curItem to folder todayDate of thisFolder end try end if end repeat end tell end adding folder items to |
今日一日書き換えたソースでうまく動作してます。
ちなみに設定ファイルパスですが同僚のMavericksではユーザーフォルダでは認識しなかったのでHD直下のLibrary>Scripts>Folder Action Scriptsに保存で認識しました。
- 2013年10月24日木曜日
- :Naruhiko Wakai
comments