Bulk renaming photos

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Husse

Bulk renaming photos

Post by Husse »

I import from two digital cameras (one camera and one phone)
Datestamp on the phone is accurate and I try to keep it correct in the camera too
I want to rename the pictures with date+time as that makes much more sense than DSC001 and the like
I've seen solutions that are a bit towards this, but not a satisfactory solution
Then looking at a photo of my wife or me it's easy to see how much we age :)
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
scorp123
Level 8
Level 8
Posts: 2272
Joined: Sat Dec 02, 2006 4:19 pm
Location: Switzerland

Post by scorp123 »

Try this:

Code: Select all

apt-cache search rename | sort | more
... and then take a good look at the list you get. There are a few candidates that you could check out .... e.g. gwenrname, krename, mrename, renameutils, purrr ...... Take a closer look at those packages, e.g.

Code: Select all

apt-cache show purrr
... I am sure one or the other package should be able to do what you want.

Or you write a nice shell script :D
Husse

Post by Husse »

Or you write a nice shell script
I could probably write that and more, but it takes time to learn - lets say python - and then write it :)
I don't want to spend all my time tied to the computer - my wife needs some attention too :lol:
scorp123
Level 8
Level 8
Posts: 2272
Joined: Sat Dec 02, 2006 4:19 pm
Location: Switzerland

Post by scorp123 »

Husse wrote: but it takes time to learn - lets say python - and then write it :)
Yeah right. :lol: We write complicated Python programs (and we'd need to learn the language first :roll: ) for stuff the shell can already do more efficiently out of the box and right away. :shock:

Very efficient :lol:

Seriously: All you need is a decent for ... do ...; done loop in bash and then have it auto-move your files into their new names. It would of course help if you e.g. had provided a listing of the files so we can see their names :wink:
User avatar
newW2
Level 5
Level 5
Posts: 821
Joined: Fri Apr 06, 2007 10:24 am
Location: USA

Post by newW2 »

Like this? Got it from some how-to script writing site, and it works well with wild cards.

#!/bin/bash

search=`gdialog --title "Rename files" --inputbox "Search for" 200 450 2>&1` || exit
replace=`gdialog --title "Rename files" --inputbox "Replace with" 200 450 2>&1` || exit

path=`echo -n "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | head -n 1 | sed 's/[^\/]*$//'`

while [ $# -gt 0 ]; do
newname=`echo "$1" | sed -e "s/$search/$replace/g"`
mv "$path$1" "$path$newname"
shift
done
Husse

Post by Husse »

Thanks both of you :)
gwenrename does the job - just have to convince it to use it's option for profiles and I'm done...
@scorp
There are all sorts of names for the existing pictures.....
dsc+number image+number "normal descriptive name"
scorp123
Level 8
Level 8
Posts: 2272
Joined: Sat Dec 02, 2006 4:19 pm
Location: Switzerland

Post by scorp123 »

My HP cameras always produce files that start with the letters hpim.... something. So if I wanted to do something like you I'd do it like this.

Original directory listing (produced with 'ls -A1'):

Code: Select all

...
hpim2043.jpg
hpim2044.jpg
hpim2045.jpg
hpim2046.jpg
hpim2047.jpg
hpim2048.jpg
hpim2049.jpg
hpim2050.jpg
hpim2052.jpg
hpim2053.jpg
hpim2054.jpg
hpim2055.jpg
hpim2056.jpg
hpim2057.jpg
hpim2058.jpg
hpim2059.jpg
hpim2060.jpg
hpim2061.jpg
hpim2062.jpg
hpim2063.jpg
hpim2064.jpg
hpim2065.jpg
hpim2066.jpg
hpim2067.jpg
...
This simple 'for' loop here (yes, this program is a 1-liner!) will copy them to their new filenames using their time stamps:

Code: Select all

for d in `ls -A1 hpim* | cut -c -8`; do NEWFILEEND=`ls -Al $d* | awk '{ print $6,$7}' | tr " " "_"`; cp $d"_"$NEWFILEEND".jpg"; done
Directory listing afterwards:

Code: Select all

...
hpim1587_2007-01-24_20:41.jpg
hpim1589_2007-01-24_20:41.jpg
hpim1590_2007-01-24_23:21.jpg
hpim1591_2007-01-24_23:22.jpg
hpim1592_2007-01-24_23:22.jpg
hpim1593_2007-01-24_23:22.jpg
hpim1594_2007-01-26_06:31.jpg
hpim1595_2007-01-26_06:32.jpg
hpim1596_2007-02-01_21:32.jpg
hpim1597_2007-02-01_21:32.jpg
hpim1598_2007-02-01_21:33.jpg
hpim1599_2007-02-01_21:33.jpg
hpim1601_2007-02-01_21:33.jpg
hpim1602_2007-02-01_21:33.jpg
hpim1603_2007-02-02_02:55.jpg
hpim1605_2007-02-02_02:59.jpg
hpim1610_2007-02-02_03:06.jpg
hpim1613_2007-02-02_03:07.jpg
hpim1614_2007-02-02_03:08.jpg
hpim1617_2007-02-03_00:31.jpg
hpim1619_2007-02-03_00:31.jpg
hpim1620_2007-02-03_00:32.jpg
hpim1621_2007-02-03_00:32.jpg
hpim1625_2007-02-03_22:27.jpg
hpim1627_2007-02-03_22:28.jpg
hpim1629_2007-02-04_00:37.jpg
hpim1632_2007-02-04_00:55.jpg
hpim1634_2007-02-04_05:53.jpg
hpim1635_2007-02-04_05:53.jpg
hpim1636_2007-02-14_06:59.jpg
hpim1637_2007-02-14_06:59.jpg
...
All done in the the shell with standard shell commands :D
Husse

Post by Husse »

Nice
We have two cameras
one producing DSC+number one producing Imag+number
and added to that there were some files renamed to things like Kerstin (my wifes name) with flowers
Gwenrename fixed it as soon as I removed all double files
Locked

Return to “Other topics”