I need to create a report of all files renamed with the ff fields in the CSV formatted report (Output.rpt).I need an output that displays
a. Column1 = Original Filename b. Column2 = Original Timestamp date c. Column3 = Renamed filename value
below is my code for x number of files that i have created with the original file name.
for i in {1938..2037}; do ## create a file with a random month touch -d "${i}-$((RANDOM % 12 + 1))-01" file_$((i-1937)) done Output is below: -rw-r--r-- 0 Oct 1 2037 file_100 -rw-r--r-- 0 Jul 1 2036 file_99 -rw-r--r-- 0 Sep 1 2035 file_98 -rw-r--r-- 0 Jan 1 2034 file_97
Below is my script for renaming the files with timestamps
for f in * do ref=$(stat -c %y "$f" | awk '{print $1}') mon=$(date -d "$ref" +%b) year=$(date -d "$ref" +%Y) mv -- "$f" "file_${mon^^}${year}" done Output: -rw-r--r-- 0 Oct 1 2037 file_OCT2037 -rw-r--r-- 0 Jul 1 2036 file_JUL2036 -rw-r--r-- 0 Sep 1 2035 file_SEP2035 -rw-r--r-- 0 Jan 1 2034 file_JAN2034