My JREN.BAT regular expression renaming utility is perfect for this problem. It is pure script (hybrid JScript/batch) that runs natively on any Windows machine from XP onward. Full documentation is built into the script, and can be reached by executing jren /?
(or jren /??
if you want paged help).
JREN.BAT allows you to match and rename files using regular expressions, and the replacement string can be a JScript expression. Built into the utility is a sophisticated timestamp formatting function that makes the job really easy.
The following one liner will rename all "rec.EpochTime.mp3" files in the current directory to
"MM-DD-YYYY_hh-mm-ss.mp3" format. It will convert the epoch time using your local time zone. There are additional options that allow you to specify a specific time zone for the output.
jren "^rec\.(\d+)\.mp3$" "ts({dt:$1,fmt:'{mm}-{dd}-{yyyy}_{hh}-{nn}-{ss}.mp3'})" /j
But I strongly advise that you change the date format from MM-DD-YYYY to YYYY-MM-DD instead. This allows you to easily sort your directory listings chronologically. The {iso-dt}
format is shorthand for {yyyy}-{mm}-{dd}
.
jren "^rec\.(\d+)\.mp3$" "ts({dt:$1,fmt:'{iso-dt}_{hh}-{nn}-{ss}.mp3'})" /j
Given that JREN is itself a batch script, you should use CALL JREN if you put the command within another batch script.