« 2000年の灯り 2012年の灯り Bright Lights, Big City | トップページ | qlmarkdown »

[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





フォルダ名をアンダースコアで分けるか?は以下を書き換えで





Website_image20121209_161334





Website_image20121209_161349


Kさん
わからなければ電話してください
忘年会で山崎1杯で良いです。w





「makefolderAlot.scpt.zip」をダウンロード


「makefolderAlot.rtf」をダウンロード





   

|

« 2000年の灯り 2012年の灯り Bright Lights, Big City | トップページ | qlmarkdown »

AppleScriptFolder」カテゴリの記事