Author Topic: Rename and move to new DIR structure - newbie question...  (Read 3210 times)

laabak

  • Newbie
  • *
  • Posts: 3
Rename and move to new DIR structure - newbie question...
« on: September 15, 2012, 06:53:14 AM »
Hi! I searched and tried several options, but i can't get this up and running...

I have a directory /media/data/Images/ with a lot of subfolders that contains unorganized images.
1) I would like to move ALL images from /media/data/Images/ (and all subfolders) into /media/data/Imagearchive/yyyy/mm/dd/cameramake/
2) In the same operation, or separately, i would like to rename the images to: Make_Model_yyyy_mm_dd_hhmmss_##.extension
3) If there are two images with the same name after rename, i would like to have a number where the ## is...

EDIT: The yyyy-mm-dd_hhmmss from both directory and filename should be the date the image was captured according to exif (i have moved this images around so the date the file was created has changed...). Also, for images not containing exif data , i would like them to land in /media/data/Imagearchive/NOEXIF/


Is there an easy way of achieving this ? I am not very familiar with scripts, so i was hoping i could do this from the command line, without writing any script...

Thanks in advance!
« Last Edit: September 15, 2012, 07:40:14 AM by laabak »

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 17231
    • ExifTool Home Page
Re: Rename and move to new DIR structure - newbie question...
« Reply #1 on: September 15, 2012, 08:53:32 AM »
This is a bit tricky to do because you are mixing embedded metadata with 2 different date/time formats (one for the directory and one for the file name).  Normally you would set the directory and filename together, but in this case it is easier to do in 2 passes:

Pass 1a: move files with EXIF into the proper directory:

exiftool '-directory</media/data/Imagearchive/$datetimeoriginal/$make' -d "%Y/%m/%d" -r  /media/data/Images

Pass 1b: move files with no EXIF:

exiftool '-directory</media/data/Imagearchive/NOEXIF' -r  /media/data/Images

Pass 2: rename the files (with EXIF):

exiftool '-filename<${make}_${model}_$datetimeoriginal%+c.%e' -d "%Y_%m_%d_%H%M%S" -r /media/data/Imagearchive

Note: The single quotes above are for Mac/Linux systems.  You need to use double quotes instead on Windows.

The only complication is that you probably also want to do some re-formatting of the Make and Model tags.  This can be done with user-defined tags.  See this post for examples.  And read here for documentation on the file renaming feature.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

laabak

  • Newbie
  • *
  • Posts: 3
Re: Rename and move to new DIR structure - newbie question...
« Reply #2 on: September 15, 2012, 09:24:58 AM »
Hi! I'll give this a try right away.
Thank you so much for your help, and for a great program as well! :)

laabak

  • Newbie
  • *
  • Posts: 3
Re: Rename and move to new DIR structure - newbie question...
« Reply #3 on: September 15, 2012, 09:41:30 AM »
Phil, one more question;

from the
exiftool '-directory</media/data/Imagearchive/$datetimeoriginal/$make' -d "%Y/%m/%d" -r  /media/data/Images

- if i have images with the same name when moving - what will happen to them ?

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 17231
    • ExifTool Home Page
Re: Rename and move to new DIR structure - newbie question...
« Reply #4 on: September 15, 2012, 03:08:36 PM »
ExifTool won't move any images if there is already an existing destination file with the same name.  Add "%c" to the filename to resolve problems like this.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).