[wplug] bash script for numbering filenames by date

Russ Schneider russ at sugapablo.com
Mon Jun 21 10:14:23 EDT 2004


I have a little bash script (just a simple command line):
q=1; for i in *.jpg; do mv "$i" `echo $q"_"$i`; let q+=1; done;

This will add as a prefix a sequential number to the beginning of each JPG
file in the current directory followed by an underscore.

Two problems that I'm not good enough in shell commands to conquer:

1) I'd like the numbers to begin at 001 (and follow 002,003,004) as in 
terms of alphabetcal order, 100 comes before 2, 3, 4, etc.

and

2) I'd like to number the files in terms of file dates and not file names.  
I.e. currently the above command(s) number the files in order of their 
filenames whereas I'd like to do it based on the dates associated with 
them.

Any suggestions?

-- 
[ Russ Schneider (a.k.a. Sugapablo)     ]
[ http://www.sugapablo.com <--music     ]
[ http://www.sugapablo.net <--personal  ]
[ sugapablo at 12jabber.com   <--jabber IM ]



More information about the wplug mailing list