|
|
#1 (permalink) |
|
Gold Member
![]() Join Date: Dec 2006
Posts: 266
|
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! |
|
|
|
|
|
#2 (permalink) |
|
VIP Member
![]() Join Date: Apr 2006
Location: Kansas City, MO
Posts: 6,056
|
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 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
forgot to add this link too, gui based app http://www.icewalkers.com/Linux/Soft...20460/mvb.html Last edited by tlarkin; 05-31-2007 at 08:41 PM. |
|
|
|
|
|
#4 (permalink) |
|
Gold Member
![]() Join Date: Dec 2006
Posts: 266
|
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. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Which linux | Arm_Pit3 | Operating Systems | 13 | 01-20-2008 03:49 PM |
| why Linux is better than window | alohanema | Operating Systems | 38 | 11-19-2007 03:33 PM |
| Linux Program | BrandonL | Operating Systems | 4 | 11-15-2005 04:00 AM |
| Linux Questions | Rexhasta | Operating Systems | 9 | 10-05-2005 10:29 PM |
| os ??? | bloospoon | Operating Systems | 8 | 07-22-2004 10:55 PM |