This is a one-liner for adding zeros to filenames in UNIX. I give it here for my own future reference, lest I have to spend this long yet again to figure out where every backtick, single-quote, and semicolon should go.
for file in `find . -maxdepth 1 -type f -print`; do mv $file `basename $file|sed -r 's/([a-z])([0-9])$/\10\2/'`; done
The difficult part here is the sed replacement, which looks for a letter followed by a number, and replaces it with the letter, then a zero, then the number.
I don't have a lot to say, but this is my little bit.
Wednesday, October 6, 2010
Subscribe to: Post Comments (Atom)
Post a Comment