HOME > AppleScript > ガチャコンX のカプセルをオモチャの名前にリネーム

Mac OS X 10.4.5 で動作確認。
「カプセル」内のガチャコンX のオモチャを選択して実行。


tell application "Finder"
set fileList to selection
set theFile to (item 1 of fileList)
set aName to (displayed name of theFile)
set theContainer to container of theFile
set containerName to (URL of theContainer)
set encodedContainerName to (do shell script "basename " & (quoted form of containerName))
set the clipboard to encodedContainerName
if (number of items of fileList > 1) then
display dialog "ガチャコンX のオモチャを1つだけ選択してください。" buttons {"キャンセル"} default button 1
else if (encodedContainerName does not contain "%E3%82%AB%E3%83%95%E3%82%9A%E3%82%BB%E3%83%AB") then
display dialog "親フォルダの名前に「カプセル」という文字列が含まれていないと無効です。ごめんなさい。" buttons {"ヴァー"} default button 1
end if
set aName to (do shell script "echo " & quoted form of aName & " | sed 's/\\.app$//;s/\\.html$//'")
set finalName to my displayName(aName, theContainer)
set (name of theContainer) to finalName
end tell

on displayName(aName, theContainer)
tell application "Finder"
set theResult to text returned of (display dialog POSIX path of (theContainer as Unicode text) & return & "を次の名前にリネーム。" & return & "" default answer aName)
if exists folder theResult of (container of theContainer) then
display dialog "同名のフォルダが存在します。"
my displayName(aName, theContainer)
return theResult
end if
end tell
end displayName

HOME > AppleScript > ガチャコンX のカプセルをオモチャの名前にリネーム


created: 2006-03-22T22:59:23+09:00
last modified: 2006-04-04T00:37:03+09:00
author: AquaBowler