ramdisc
Group: Members
Posts: 1
Joined: Oct. 2005 |
|
Posted: Oct. 27 2005,15:53 |
|
Hello,
I need help writing a piece of bash.
What I am trying to do is get a bash script to target single digit file names and convert them to double digits. Lets say this is what I have in my folder:
1.jpg 10.jpg 11.jpg 12.jpg 2.jpg 20.jpg 3.jpg 4.jpg 5.jpg 1.txt 2.txt
I would like the bash script to rename 1.jpg, 2.jpg, 3.jpg, 4.jpg, and 5.jpg into 01.jpg, 02.jpg, 03.jpg, 04.jpg and 05.jpg. At the same time not mistakening the 11.jpg and 12.jpg as as 1.jpg and 2.jpg
The bash script will only target *.jpg formats so conflicts with 1.txt and 2.txt does not occour.
Okay, this is my newbism:
Code Sample | seq=(`seq 1 9`) file=(ls $seq.jpg) if $file then for loop in $file do mv $loop 0$loop done |
Like I said, my newbism.
How do I make this script functional? Please help.
Thanks in advance.
|