OS X -Applescriptファイルを毎日別のフォルダーに移動することについての質問(フォルダは異なります)
-
16-10-2019 - |
質問
私は現在これを使用しています( http://lifehacker.com/193778/download-of-the-day-auto+applescript-tickler-file )Ticklerファイルシステムの場合、Dropboxでセットアップしてください(システム全体で動作します)。それを完璧にすることから、ほんのいくつかのことがあります。誰かが私を助けることができれば、それは素晴らしいでしょう。
私が目指しているのは、前日にフォルダーのコンテンツを取得するスクリプトまたはワークフローです(毎日変更され、番号が付けられています)。それで、私は毎日朝に演奏するためのアラームとしてそれを設定することができます。
どうもありがとう。
解決
私があなたの要件を正しく理解しているなら、このスクリプトはあなたが望むことを行うべきです。最初の行のユーザー名をユーザー名に変更してください。
set username to "lizzan"
set cy to (year of (current date)) as integer
set cm to (month of (current date)) as integer
set cd to (day of (current date)) as integer
set yd to yesterday(cy, cm, cd)
set yy to item 1 of yd
set ym to item 2 of yd
set yd to item 3 of yd
set yFolder to "Macintosh HD:Users:" & username & ":Documents:To Do:" & yy & ":" & ym & ":" & yd
set cFolder to "Macintosh HD:Users:" & username & ":Documents:To Do:" & cy & ":" & cm & ":" & cd
tell application "Finder"
move every file of folder yFolder to cFolder
end tell
on yesterday(y, m, d)
set d to d - 1
if d ≤ 0 then
set m to m - 1
if m ≤ 0 then
set y to y - 1
set m to 12
end if
set thirtyones to {1, 3, 5, 7, 8, 10, 12}
set thirties to {4, 6, 9, 11}
if m is in thirtyones then
set d to 31
else if m is in thirties then
set d to 30
else if leapyear(y) then
set d to 29
else
set d to 28
end if
end if
set yd to {y, m, d}
return yd
end yesterday
on leapyear(y)
if y mod 4 is 0 then
if y mod 100 is 0 then
if y mod 400 is 0 then
return true
end if
return false
end if
return true
end if
return false
end leapyear
警告:スクリプトは失敗します(そして、ファイルの一部のみを移動した可能性があります)。その場合のファイルを交換し、失敗を避けたい場合は、追加してください with replacing
18行目の終わりに(move every ... to cFolder with replacing
).
追加するために編集: ああ、ドキュメントフォルダーではなく、ドロップボックスに設定していることがわかりました。 14行目と15行目のパスを変更して、使用しているパスを反映するだけで問題ありません。
他のヒント
非常に単純な解決策は、です 自動車アプリケーション (独立して実行されるワークフロー)。このワークフローを設定するのに約15秒(文字通り)かかりました。
所属していません apple.stackexchange