Para renomear de verdade, remova a palavra echo
.
ls -l file_* |
awk '
BEGIN {
OFS=",";
print "Original filename", "Original timestamp", "Renamed filename" > "output.rpt";
}
{
renamed_filename = "file_" toupper($6) $8;
original_timestamp = sprintf("%d-%s-%02d", $8, $6, $7);
exit_status = system("echo mv -v -- " $9 " " renamed_filename);
if(!exit_status)
print $9, original_timestamp, renamed_filename > "output.rpt";
}'
Arquivos originais
-rw-rw-r-- 1 user user 0 Jul 1 1938 file_1
-rw-rw-r-- 1 user user 0 Sep 1 1947 file_10
-rw-rw-r-- 1 user user 0 May 1 2037 file_100
Comandos de renomeação gerados
mv -v -- file_1 file_JUL1938
mv -v -- file_10 file_SEP1947
mv -v -- file_100 file_MAY2037
output.rpt
### Comma-separated values.
$ cat output.rpt
Original filename,Original timestamp,Renamed filename
file_1,1938-Jul-01,file_JUL1938
file_10,1947-Sep-01,file_SEP1947
file_100,2037-May-01,file_MAY2037
### Pretty printed by the 'column' command.
$ cat output.rpt | column -t -s,
Original filename Original timestamp Renamed filename
file_1 1938-Jul-01 file_JUL1938
file_10 1947-Sep-01 file_SEP1947
file_100 2037-May-01 file_MAY2037