[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: reorder files with a mouse in a file browser and rename them



On 06/09/2007 11:28 PM, H.S. wrote:
[...]
I am looking for a method to drag and move file1.jpg to the bottom of the list and then to rename them based on a file pattern to get
001_file2.jpg
002_file3.jpg
003_file1.jpg

Only that I do not have only three files, a few hundred of them.


Use drag and drop to move the files into another directory, the execute a script like this in that directory:

-------------------------------
#!/bin/bash
count=0
ls -U file*.jpg | while read filename
do
    count=$(( $count+1 ))
    fcount=`printf "%03d" $count`
    echo mv $filename ${fcount}_$filename
done
-------------------------------

If you want to use this script, you should test it with the "echo" still in there. Then you can get rid of the "echo" when you're sure the script works correctly.

I hope this helps.



Reply to: