Computing.Net > Forums > Unix > Shell script Bash

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Shell script Bash

Reply to Message Icon

Name: hasumedic
Date: November 21, 2005 at 09:19:21 Pacific
OS: Linux
CPU/Ram: P4 1024
Comment:

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.txt

to

File.51.txt
File.52.txt
File.53.txt

etc..

Or

File.0016.txt
File.0017.txt
File.0018.txt

to

File.0131.txt
File.0132.txt
File.0133.txt

etc..

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.##.txt

File.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!!



Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Declaring a variable gamble with varible conte...



Post Locked

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


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Shell script Bash

Bash Shell Script www.computing.net/answers/unix/bash-shell-script/8258.html

backup a file with SHELL SCRIPT www.computing.net/answers/unix/backup-a-file-with-shell-script/4522.html

Shell script for network test www.computing.net/answers/unix/shell-script-for-network-test/7976.html