I’d like to rename some files that are all in the same directory. The file name pattern used is Prefix_ddmmyy.tex with a european date format. For the sake of readability and the ordering I’d like to rename the files in a pattern Prefix_yymmdd.tex with a canonical date format.
Anyone ideas how I can do this automatically for a complete directory? My sed and regexp knowledge is not very sharp…
for file in Prefix_*.tex ; do file_new=
echo '$file' | sed -e 's:\([0-9][0-9]\)\([0-9][0-9]\)\([0-9][0-9]\)\(\.tex\):\3\2\1\4:'test ‘$file’ != ‘$file_new’ && mv -f ‘$file’ ‘$file_new’ doneOr, if you have a lot of files and/or want to process files recursively, replace:
with:
or (non-recursive, GNU):