Linux - mass rename

Jonyboy

New Member
Hi all, so i've been using linux for a long time but have only recently stumbled across this kind of task.

If i had a group of images from a camera (and they went like..)

img-001.jpg, img-002.jpg, img-003.jpg, img-004.jpg etc... (up to say 100)

how would i be able to do a mass rename and turn them into

Europe-2007-001.jpg, Europe-2007-002.jpg, Europe-2007-003.jpg etc...

Any programs or command line tools you know of, cause i've googled around to no avail, thanks all!
 
well a simple shell script may do the trick, I would test this out before doing it though

open up your console (terminal) and from the CLI change into your pic directory

now you can do this as an example

Code:
mv \*.jpeg \newname.jpeg

I also found this shell script that will do it massively

Code:
EXTENSION=.jpg

LOGFILE=./log.filemove

TIMESTAMP=$(date +%G%m%d%H%M)

# Loop through every file in the current directory
# with the appropriate extension and rename it to
# the form SUBJECT[RANDOM NUMBER].[EXTENSION]

for FILE in *"$EXTENSION"; do

NEWNAME="SUBJECT${RANDOM}${EXTENSION}"

# Sanity check to make sure the script doesn't
# overwrite a previously renamed file. This is
# unlikely, but we want to check for it to be
# sure.
#Make sure to modify this part so it uses the right name

while [ -e "$NEWNAME" ]; do
NEWNAME="SUBJECT${RANDOM}${EXTENSION}"
done

# Rename the file to its new randomized form

mv $FILE $NEWNAME

# Log the name change mapping

printf '%s\t%s\n' "$FILE" "$NEWNAME" >> $LOGFILE

# Change the timestamp to match for each file
# and further remove differentiating file
# information (differing timestamps) that might
# lead to subconscious research bias

touch -t $TIMESTAMP $NEWNAME

done

**EDIT

forgot to add this link too, gui based app

http://www.icewalkers.com/Linux/Software/520460/mvb.html
 
Last edited:
IT WORKED! I downloaded that program (script) and it's really easy to use. 10/10 thanks man. Dowloaded it and within 5 minutes i had done it. Thanks.
 
I have another "problem" now. I've managed to rename all of my pictures (in multiple folders) but would like to bring all of the images into one folder (with no sub folders).

so i would change

./xyz/1/europe-2007-001.jpg (and the other hundred)

and

./xyz/2/cyprus-2005-001.jpg (and the other hundred)

into

./xyz/europe-2007-001.jpg
./xyz/cyprus-2005-001.jpg

so i could have all my photos in one directory.

-------

I was thinking about going through this by copying and pasting in the GUI (but i have 20 folders to copy from) and although i wouldn't mind doing that i feel there must be an easier way and that i should learn more about Linux, and i wouldn't mind making a shell script but i don't know how to use the cp command and only copy the contents.
 
Back
Top