[AppleScript]フォルダを連番で複数作る
一度に多数のフォルダを作成します
連番を付加します
連番にゼロサプレスを付けた形
たぶん
日付フォルダに使うんでしょ?
tell application "Finder"
-------------------------------------------------フォルダ名ダイアログのデフォルトアンサー用に年月を求める
set theMonth to do shell script "date '+%Y%m'" as text
-------------------------------------------------フォルダを選択
set theFolderAlias to choose folder "フォルダを選択" default location (path to desktop folder from user domain)
-------------------------------------------------フォルダ名を入力
display dialog "フォルダ名を入力" default answer theMonth buttons {"Set", "Cancel"} with icon 1 default button 1 with title "フォルダ名を入力" cancel button "Cancel"
-------------------------------------------------フォルダを取得してテキストとして格納
if button returned of the result is "Set" then
set theMainFolderName to text returned of the result as text
end if
-------------------------------------------------個数を入力
display dialog "いくつフォルダを作りますか" default answer "31" buttons {"Make", "Cancel"} with icon 1 default button 1 with title "数字入力" cancel button "Cancel"
-------------------------------------------------個数を取得して数字で格納
if button returned of the result is "Make" then
set theNoFolderName to text returned of the result as number
--------------------繰り返し用にも数字を用意しておく
set theCreateNo to theNoFolderName as number
end if
-------------------------------------------------個数が何桁かを判定
set theCntNo to the length of characters of (theNoFolderName as text) as number
-------------------------------------------------個数の初期化
set theCreateNo to 0 as number
-------------------------------------------------■■■■■■■ここから繰り返し部
repeat while theNoFolderName > theCreateNo
-------------------------------------------------個数に1を足す
set theCreateNo to theCreateNo + 1 as number
-------------------------------------------------4桁までのゼロサプレス処理(4桁は実用的ではないなw)
if theCntNo = 2 then
if theCreateNo < 10 then
set theFcount to "0" & theCreateNo as text
else
set theFcount to theCreateNo as text
end if
else if theCntNo = 3 then
if theCreateNo < 10 then
set theFcount to "00" & theCreateNo as text
else if theCreateNo < 100 then
set theFcount to "0" & theCreateNo as text
else
set theFcount to theCreateNo as text
end if
else if theCntNo = 4 then
if theCreateNo < 10 then
set theFcount to "000" & theCreateNo as text
else if theCreateNo < 100 then
set theFcount to "00" & theCreateNo as text
else if theCreateNo < 1000 then
set theFcount to "0" & theCreateNo as text
else
set theFcount to theCreateNo as text
end if
else
set theFcount to theCreateNo as text
end if
-------------------------------------------------フォルダ名を定義 アンダースコアで分ける
set theFolderName to theMainFolderName & "_" & theFcount
-------------------------------------------------フォルダ名を定義
----set theFolderName to theMainFolderName & theFcount
-------------------------------------------------#フォルダを作る
try
make new folder at theFolderAlias with properties {name:theFolderName}
end try
-------------------------------------------------繰り返しの終了
end repeat
-------------------------------------------------処理の終了
end tell
フォルダ名をアンダースコアで分けるか?は以下を書き換えで
Kさん
わからなければ電話してください
忘年会で山崎1杯で良いです。w
「makefolderAlot.scpt.zip」をダウンロード
| 固定リンク
「AppleScriptFolder」カテゴリの記事
- [MDLS]mdlsでフォントファミリー名を取得する(2014.12.31)
- [AppleScript]フォルダを連番で複数作る(2012.12.09)
- [Move]フォルダの移動(2010.09.15)
- [AppleScript]フォルダのアクセス権を変更する(2010.08.10)
- [AppleScript]ファイル名のフォルダを作ってその中に入れる(2010.08.05)