新規フォルダを作る
最前面にあるファインダーウィンドウに、新規フォルダを作るAppleScript。ついでに、デフォルトでは今日の年月日がフォルダ名になるようにした。年月日時分秒にすることも可能だし、そうすればフォルダ名の重複は防げるが、無駄に長くなるのがイヤなので、年月日+2桁数字にした。同じ名前がなかったら作る、あったら「同じ名前」+「-02」・・・という原始的な方式。

「do shell script」というのはよくわからんけど「UNIX コマンド」らしい。と言われても相変わらずわからんけど、ちなみに "date +%y.%m.%d" の中の「y」を大文字に変えると、西暦が4桁になる。「crntDt」はカレント・デイト、すなわち今日の日付というつもり。賢い人はこんな独自の省略形を使わず、「current_Date」とかにするらしい。「window 1」をすべて「desktop」に置換すると、デスクトップにフォルダを作るスクリプトになる。

●サンプルスクリプト
on getCurrentDate()
-- yy-mm-dd のフォーマットで日付を取得する
do shell script "date +%y.%m.%d"
end getCurrentDate
set crntDt to my getCurrentDate()

tell application "Finder"
activate

display dialog "Type new folder name:" default answer crntDt
set aName to text returned of result
set aName01 to aName & "-01"
set aName02 to aName & "-02"
set aName03 to aName & "-03"
set aName04 to aName & "-04"
set aName05 to aName & "-05"
set aName06 to aName & "-06"
set aName07 to aName & "-07"
set aName08 to aName & "-08"
set aName09 to aName & "-09"

set aName10 to aName & "-10"
set aName11 to aName & "-11"
set aName12 to aName & "-12"
set aName13 to aName & "-13"
set aName14 to aName & "-14"
set aName15 to aName & "-15"
set aName16 to aName & "-16"
set aName17 to aName & "-17"
set aName18 to aName & "-18"
set aName19 to aName & "-19"
set aName20 to aName & "-20"

if not (exists folder aName of window 1) then
make new folder at window 1 with properties {name:aName}
open folder aName of window 1
else if not (exists folder aName02 of window 1) then
make new folder at window 1 with properties {name:aName02}
open folder aName02 of window 1
else if not (exists folder aName03 of window 1) then
make new folder at window 1 with properties {name:aName03}
open folder aName03 of window 1
else if not (exists folder aName04 of window 1) then
make new folder at window 1 with properties {name:aName04}
open folder aName04 of window 1
else if not (exists folder aName05 of window 1) then
make new folder at window 1 with properties {name:aName05}
open folder aName05 of window 1
else if not (exists folder aName06 of window 1) then
make new folder at window 1 with properties {name:aName06}
open folder aName06 of window 1
else if not (exists folder aName07 of window 1) then
make new folder at window 1 with properties {name:aName07}
open folder aName07 of window 1
else if not (exists folder aName08 of window 1) then
make new folder at window 1 with properties {name:aName08}
open folder aName08 of window 1
else if not (exists folder aName09 of window 1) then
make new folder at window 1 with properties {name:aName09}
open folder aName09 of window 1

else if not (exists folder aName10 of window 1) then
make new folder at window 1 with properties {name:aName10}
open folder aName10 of window 1
else if not (exists folder aName11 of window 1) then
make new folder at window 1 with properties {name:aName11}
open folder aName11 of window 1
else if not (exists folder aName12 of window 1) then
make new folder at window 1 with properties {name:aName12}
open folder aName12 of window 1
else if not (exists folder aName13 of window 1) then
make new folder at window 1 with properties {name:aName13}
open folder aName13 of window 1
else if not (exists folder aName14 of window 1) then
make new folder at window 1 with properties {name:aName14}
open folder aName14 of window 1
else if not (exists folder aName15 of window 1) then
make new folder at window 1 with properties {name:aName15}
open folder aName15 of window 1
else if not (exists folder aName16 of window 1) then
make new folder at window 1 with properties {name:aName16}
open folder aName16 of window 1
else if not (exists folder aName17 of window 1) then
make new folder at window 1 with properties {name:aName17}
open folder aName17 of window 1
else if not (exists folder aName18 of window 1) then
make new folder at window 1 with properties {name:aName18}
open folder aName18 of window 1
else if not (exists folder aName19 of window 1) then
make new folder at window 1 with properties {name:aName19}
open folder aName19 of window 1
else if not (exists folder aName20 of window 1) then
make new folder at window 1 with properties {name:aName20}
open folder aName20 of window 1
end if

end tell

●サンプルスクリプトの使い方
[PR]
by nobiox | 2012-07-01 17:41 | ├バカスクリプト |
<< 【問題】コインを2枚投げたら1... | inDesign のウィンドウ... >>