I have folders I upload files to, with 1,000-20,000 files of different kinds (pdf, jpg, wmv...etc) with different file names and lengths with spaces in the names, etc.
I am trying make a script to rename them on a regular basis, but I want them sorted by "oldest date first", and the new name will be in the format of YYYT000001.xxxx ... YYYY036242.xxxx (where YYYY is a fixed text "Jan" or Dec" (I will enter it manually in the script), and xxxx is the original file extension).
I've tried to use the input for i in $(ls -tr)
as it will be sorted by oldest date, and tried to replace the file names using basename $i
, etc.
I have searched the net but my thick head could not come up with a working script.