LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Blogs > linux-related notes
User Name
Password

Notices

Just annotations of little "how to's", so I know I can find how to do something I've already done when I need to do it again, in case I don't remember anymore, which is not unlikely. Hopefully they can be useful to others, but I can't guarantee that it will work, or that it won't even make things worse.
Old

Auxiliary script to rename multiple files adding a zero-padding to them

Posted 08-19-2014 at 12:37 AM by the dsc (linux-related notes)

From this blog:

http://www.walkingrandomly.com/?p=2850


Code:
#!/bin/bash
num=`expr match "$1" '[^0-9]*\([0-9]\+\).*'`
paddednum=`printf "%03d" $num`
echo ${1/$num/$paddednum}
Usage example:

for i in *.png;do mv $i `./zeropad.sh $i`; done


Possibly there's some syntax to do just that only with the "rename" command, though.
Member
Posted in Uncategorized
Views 121 Comments 0 the dsc is offline

  



All times are GMT -5. The time now is 10:41 PM.

Main Menu
Advertisement

My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration