数百あるフォルダの第一階層だけコピーしたかったけど、容量が数十GBあり、コピー後中身を削除するのも効率的じゃないので、書いてみました。
ドラッグ&ドロップしたフォルダと同じ名前のフォルダを指定先に作成するAppleScriptです。
新規作成したフォルダのラベルの設定はドラッグ&ドロップしたフォルダと同じになります。
ドラッグ&ドロップしたフォルダの中身はコピーしません。
AppleScript
on open thisListtell application "Finder"
set check to 0
set newFolMake to choose folder with prompt "フォルダの作成先を選択してください" as Unicode text
repeat with thisFile in thisList --ファイル数分繰り返す
set newFolName to my pathEtract(thisFile) --フォルダの名前取得
set labelIndex to label index of thisFile --ラベルのインデックスを代入
try
set newFol to make new folder at newFolMake with properties {name:newFolName} --フォルダ作成
set label index of newFol to labelIndex --ラベルをつける
on error
set check to check + 1
display dialog "エラーが発生したので処理をスキップします"
end try
end repeat
end tell
activate
display dialog ((count thisList) as text) & "個のフォルダを処理しました
スキップ:" & (check as text) & "個"
end open
to pathEtract(thisFile)
set pathStr to thisFile as Unicode text
--display dialog pathStr
set OriginalDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
set pathitems to text items of pathStr
set AppleScript's text item delimiters to OriginalDelimiters
--pathitemsにリストで代入されているからあとはご自由に
return item ((count pathitems) - 1) of pathitems
end pathEtract