Rename and move to new DIR structure - newbie question...

Started by laabak, September 15, 2012, 06:53:14 AM

Previous topic - Next topic

laabak

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!

Phil Harvey

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/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

laabak

Hi! I'll give this a try right away.
Thank you so much for your help, and for a great program as well! :)

laabak

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 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/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

jworthen

I have been following this same approach but have encountered a very odd issue...  when I try to execute the noexif data step, I am getting errors on every file saying "No writable tags set from [filename]".  Then the next error is "Invalid tag name '[directory]' - [filename]". 

I am not using any variables but the following command:

exiftool -r '-directory</mnt/media/librephotos/pictures/noexif'  /mnt/media/librephotos/import

I feel like I must be missing something really simple but I can't seem to figure it out...

Thanks for any help!
Jason

StarGeek

This is Common Mistake #5c

"<" is used for copying, in which case the source (right-hand-side) operand is interpreted as either
    a tag name (if the operand does not contain a "$" symbol), or
    a string containing tag names prefixed by "$" symbols (if the operand contains a "$" symbol).
"=" is used to assign a simple tag value, and the source operand is a string that is written directly to the destination tag.
(And the combination "<=" is used to assign a tag value from the contents of a file.)


You're not copying a tag to the Directory, so that's why the error is "No writable tags"

Change it to an equal sign = and it should work.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).