私はMacOSXLionを使用していますが、仮想マシンにWindows XPがあるので、Windowsのソリューションにも満足しています。
次のように、ファイル名にUNIXタイムスタンプが含まれるファイルが何百もあります。
1341131403_-_db123456.sql.gz
1341390599_-_db123456.sql.gz
1341563401_-_db123456.sql.gz
そして、タイムスタンプを読み取り可能なタイムスタンプに変換し、ファイルの名前をその読み取り可能なタイムスタンプで次のように変更したいと思います。
2012-07-01 08-30-03.sql.gz
2012-07-04 08-29-59.sql.gz
2012-07-06 08-30-01.sql.gz
私はAppleScriptソリューションに数時間を費やしましたが、成功しませんでした。
on open (the_input)
tell application "Finder"
set the_files to every item of the_input
set the_count to count of the_files
repeat with i from 1 to the_count
set current_file to item i of the_files
set old_name to (name of current_file) as string
set old_name to trim_line(old_name, "_-_db123456. sql. gz", 1)
set new_name to (result of uts_convert(old_name)) as string
set the name of current_file to (new_name & file type of current_file)
end repeat
end tell
end open
on uts_convert(input)
set shellcommand1 to "date -r "
set shellcommand2 to " \"+%Y-%m-%d %H-%M\""
set the_output to do shell script (shellcommand1 & input & shellcommand2)
return the_output
end uts_convert
どんな助けでも大歓迎です!それがapplescriptや単純なターミナルコマンドなどで行われるかどうかは気にしません。
前もって感謝します!