Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi! I have a problem with my shell script.
I need a script that rename files like:File.001.txt
File.002.txt
File.003.txtto
File.51.txt
File.52.txt
File.53.txtetc..
Or
File.0016.txt
File.0017.txt
File.0018.txtto
File.0131.txt
File.0132.txt
File.0133.txtetc..
The maximum of numbers that can contain each file is 4 (File.####.txt). How can I do that? My biggest problem is in how i put the exact number of 0's before the renamed files.
The call must be this way:
./rename.sh $1 $2 $3 $File.####.txt $File.##.txt
where
$1 is the number it starts the first file.
$2 the number it finish.
$3 the number it begins the renamed file.p.e.)
./rename.sh 1 15 71 File.###.txt File.##.txtFile.001.txt -> File.71.txt
File.002.txt -> File.72.txt
File.003.txt -> File.73.txt
File.004.txt -> File.74.txt
File.005.txt -> File.75.txt
File.006.txt -> File.76.txt
File.007.txt -> File.77.txt
File.008.txt -> File.78.txt
File.009.txt -> File.79.txt
File.010.txt -> File.80.txt
File.011.txt -> File.81.txt
File.012.txt -> File.82.txt
File.013.txt -> File.83.txt
File.014.txt -> File.84.txt
File.015.txt -> File.85.txt
Thx a lot!!

![]() |
Declaring a variable
|
gamble with varible conte...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |