Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
mkdir tmp/
mv {200..100500} tmp/
for i in {200..100500}; do mv tmp/$i ./$(expr $i + 100); done
rm tmp/
I didn’t understand what bash has to do with it and why there are some loops for this, perl scripts in 10 (O_o) lines, etc., if there are 100500 one-line solutions with different standard external utilities. And in this case, you can generally rename it simply with the rename command:
rename 2 3 2??
If perl suits, then here is a program for renaming, the first digit in the name increases by one.
The first parameter is a directory, like
rename.pl /path/to/dir
#!/usr/bin/perl
$dir = $ARGV[0];
exit if ( !-d $dir );
opendir DIR, $dir;
for $old ( grep -d "$dir/$_", readdir DIR ) {
next unless ( $old =~ /^(\d)(\d+)/ );
$new = ( $1 + 1 )."$2";
rename( "$dir/$old", "$dir/$new" );
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question