022
フォルダー内の全てのファイルを、他のフォルダーに名前を変えてコピー
時々必要になるんだけれど、毎回始めから作り直して時間を無駄にしてしまうので、
メモとして残しておきます。
AppleScriptや shell を使ってもできますが、LiveCode 純正にしてみました。
on mouseUp
answer folder ""
put it into tOriginalFolder
set the defaultfolder to tOriginalFolder
--// デフォルトフォルダーにセットすると the files で全てのフォルダー名が得られる //--
put the files into tFileList
--// MacOS の不可視ファイルを取り除く //--
filter tFileList without ".*"
--// デスクトップに新しくフォルダーを作る //--
set the defaultFolder to specialFolderPath("desktop") &"/changedFilenames"
if the result is "can't open directory" then
create folder specialFolderPath("desktop") &"/changedFilenames"
end if
set the cursor to watch
repeat for each line tLine in tFileList
--// 任意のファイル名をtNewFileName に入れる //--
--// 例では古い名前の最後の7文字をそのまま使用 //--
put "NewName" & char -7 to -1 of tLine into tNewFileName
put url ("binfile:/" & tOriginalFolder &"/" & tLine) into \
url("binfile:/"& specialFolderPath("desktop") &"/changedFilenames/" & tNewFileName)
end repeat
end mouseUp