Move part of a sequence

Hi there,

How I can do to move part of a sequence of files? For example:

I have this sequence

file.00001.jpg
file.00002.jpg
file.00003.jpg
....
file.05000.jpg

and I want to move the file file.00200.jpg to file.00010.jpg.

Thanks,

I must be missing the point:

mv file.00200.jpg file.00010.jpg

Sorry for my english.

What I meant is to move all files between file.00010.jpg and file.00200.jpg, inclusive.

Sorry for not use the tag CODE.

Thanks.

Is the idea to rename file.00200.jpg through file.05000.jpg to file.00010.jpg to the end of the list, or just file.00200.jpg through file.00389.jpg to file.00010.jpg through 00199.jpg?

What is supposed to happen if some files in the source or target range are missing? (Is the the next source file (numerically) to be moved instead, or is hole supposed to be left in the target sequence?)

what do you want to do with these files
Do you want to rename them to something else in the same directory
or do you want to move them to some other folder
Below is the code to move such files to other directory /move/to/this/path/

ls -1 | awk '{split($0, a, "."); if(a[2]+0 >= 10 && a[2]+0 <= 200) print}' | while read line
do
mv ${line} /move/to/this/path/
done

Thanks,

Yes, I want to move to other directory.

---------- Post updated 07-08-14 at 02:34 AM ---------- Previous update was 06-08-14 at 11:34 AM ----------

Sorry for my English.
I can not get the script work properly.
How I can make it work with variables for start file, end file and destination?
I've tried this code and it does not work.

I run script like this:

./move.sh start end destination

And move.sh contains:

#!/bin/tcsh -f
ls -1 | awk '{split($0, a, "."); if(a[2]+0 >= $1 && a[2]+0 <= $2) print}' | while read line
do
mv ${line} $3
done

what is it wrong?

Thanks,

You're mixing awk variables and shell variables. And, that is not the correct format for a tcsh while loop.

Try something more like:

#!/bin/ksh
ls file.*.jpg | awk -F '[.]' -v min="$1" -v max="$2" '{if($2+0 >= min && $2+0 <= max) print}' | while read line
do      mv "$line" "$3"
done

If you don't like the Korn shell, you can substitute any shell that recognizes basic Bourne shell syntax.