Author Topic: Really struggling to get my exiftool command right, please help.  (Read 241 times)

effgee

  • Newbie
  • *
  • Posts: 6
Hello Phil and Friends,

Am long time fan of exiftool but I still suck at it.
Anyways my particular use case at this time I need to help fix a horribly butchered photo collection that has survived ~6 or so disk crashes and hurried backups to various locations as well as some image application butchering of the tags, and on top of that some mixing of other peoples photos into said collections. Its a mess.

 I say this as how I need the exiftool to perform may not make alot of sense for organization to you, but it is needed to organize first to remove non belonging photos as well as identify photos messed with by apps (picasa) and the originals. Please no judgement.

I have gotten the commands to do what I want separately but because the %c function keeps count per run I need to get my rename and move done on a single execution. (lots of duplicate files due to photo programs changing tags and generating different sized version of images.. sigh)

Here is my pseudo commands, I am aware these examples do not work at the moment due to having a script of about 100 different iterations of the commands, I have lost the individual ones that were working.  :-\  :-\  :-\  :-\

exiftool -d '%Y.%m.%d-[%B.%d]-%Hh%Mm%Ss' '-filename<CreateDate-[${model;}].[${imagewidth;}x${imageheight;}]${Artist;}%c.%e' -r $SRCDIR

RESULT: 2015.04.18-[April.18]-16h36m08s-[GT-I9505].[1920x1080]Picasa.jpg

and the directory commands.
exiftool -Directory\<$DSTDIR\/[\$Make]-[\$Model]\/\$DateTimeOriginal -d '%Y.%m-[%B-%Y]' -r $SRCDIR

RESULT:
$DSTDIR/[SAMSUNG]-[GT-I9505]/2015.04-[April-2015]/2015.04.18-[April.18]-16h36m08s-[GT-I9505].[1920x1080]Picasa.jpg

My brain is fried and I need some guidance.
Important info, doing the sorting on Linux and trying to put the command in a bash script, I'm still not clear when to use single quotes '  or double quotes " and when and where to escape \ special characters.


« Last Edit: April 06, 2019, 06:59:57 AM by effgee »

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14554
    • ExifTool Home Page
Re: Really struggling to get my exiftool command right, please help.
« Reply #1 on: April 06, 2019, 07:02:47 AM »
It would help if I knew what you were trying to do, or what was going wrong.

I see nothing wrong except that there are backslashes instead of forward slashes in your final result.  But your command should have produced the proper forward slashes. 

- 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 ($).

effgee

  • Newbie
  • *
  • Posts: 6
Re: Really struggling to get my exiftool command right, please help.
« Reply #2 on: April 06, 2019, 08:35:41 AM »
Hi Phil,

In simple terms, I need to combine those two commands
This is so that the %c option properly keeps count. If I run those commands seperately since I am dealing with many subfolders the count works for files in the same directory but when I finally move them to the final destination with the directory command files dont get copied as there are file name conflicts.

I understand that putting slashes/directories in the filename will rename it to the proper destination but I cannot get it to work.

The incorrect slashes were because I was copy/pasting the result from a samba share on a windows box but I am running exiftool on linux.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14554
    • ExifTool Home Page
Re: Really struggling to get my exiftool command right, please help.
« Reply #3 on: April 06, 2019, 08:56:04 AM »
I see.  This is a bit complicated because you want to use two different date/time formats.  But this can be done using the DateFmt feature of the advanced formatting expression, like this:

exiftool -d '%Y.%m.%d-[%B.%d]-%Hh%Mm%Ss' '-filename<${CreateDate}-[${model;}].[$imagesize]${Artist;}%c.%e' "-Directory<$DSTDIR"/'[${make;}]-[${model;}]/${DateTimeOriginal#;DateFmt("%Y.%m-[%B-%Y]")}' -r $SRCDIR

Here I switch from double quotes to single quotes in in the Directory argument so that $DSTDIR is expanded by the shell while still protecting the ExifTool tag names.  I have also simplified "${imagewidth;}x${imageheight}" into just "$imagesize" since ExifTool already provides this as a Composite tag.  I also found that your CreateDate was lacking a leading "$", and requires braces before the trailing "-" because dashes are valid characters in tag names.

You could also set both the name and directory through the FileName tag like this:

exiftool -d '%Y.%m.%d-[%B.%d]-%Hh%Mm%Ss' "-filename<$DSTDIR"/'[${make;}]-[${model;}]/${DateTimeOriginal#;DateFmt("%Y.%m-[%B-%Y]")}/${CreateDate}-[${model;}].[$imagesize]${Artist;}%c.%e' -r $SRCDIR

...which I recommend because then you can do a dry run of the command using "testname" instead of "filename" to make sure it works before actually renaming/moving your files.

- 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 ($).

effgee

  • Newbie
  • *
  • Posts: 6
Re: Really struggling to get my exiftool command right, please help.
« Reply #4 on: April 06, 2019, 09:24:18 AM »
Have not yet tried the first command, am working on that now.

I tried the second command first, and it is almost correct.
It appears the DateFmt is not taking effect.

I am getting folders with the unformatted date/time from the exif tag that includes : separators

ex. /SORTED/[SAMSUNG]-[GT-I9000]/2013:09:30 18:29:56/2013.09.30-[September.30]-18h29m56s-[GT-I9000].[1920x2560]Picasa1.jpg

A sprog is missing somewhere.

effgee

  • Newbie
  • *
  • Posts: 6
Re: Really struggling to get my exiftool command right, please help.
« Reply #5 on: April 06, 2019, 10:01:17 AM »
Ok, the first command does the same behavior of ignoring DATEFMT as well, but your first command also correctly moves and renames more files although both commands were very inconsistent and did not properly rename files for unknown reasons.

For example In the PhilTest-1 results tree
├── [SONY]-[DSC-W220]
│   ├── 2010:05:01 22:39:54
│   │   ├── Εικόνα 1477.10.jpg
│   │   ├── Εικόνα 1477.11.jpg
│   │   ├── Εικόνα 1477.1.jpg
│   │   ├── Εικόνα 1477.2.jpg
│   │   ├── Εικόνα 1477.3.jpg
│   │   ├── Εικόνα 1477.4.jpg


All of these files have metadata and will rename if I run the rename command on them without moving them.

EDIT: Ok, these files rename properly if I remove ${Artist;} from the rename command, shouldn't the files rename with a blank for  ${Artist;} instead of skipping the entire rename process? Am I missing something to rename with whatever tags are availiable, ignoring any that are not?


EDIT 2: Ok, I figured out the solution regarding missing tags and failing to rename. I found the solution here: http://u88.n24.queensu.ca/exiftool/forum/index.php/topic,5079.msg24483.html#msg24483  Is there another newer way to fail gracefully when tags used in the rename command are missing? Or is just creating a hierarchy of possible naming structures in the command the "right way"

I still have not figured out why DATEFMT is not working though. Your commands match your documentation exactly, yet they dont work. Very odd.


Full pastes below

PhilTest-1 is the first command you gave me
PhilTest-2 is the second command you gave.

https://pastebin.com/XhT5KGRi    - Sample File Listing Before and After Each of Your Commands

PhilTest-1.txt Results Tree
https://pastebin.com/6AqVLEkr

PhilTest-2.txt Tree
https://pastebin.com/ycVFSAFj
« Last Edit: April 06, 2019, 11:30:51 AM by effgee »

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14554
    • ExifTool Home Page
Re: Really struggling to get my exiftool command right, please help.
« Reply #6 on: April 06, 2019, 11:51:37 AM »
EDIT 2: Ok, I figured out the solution regarding missing tags and failing to rename. I found the solution here: http://u88.n24.queensu.ca/exiftool/forum/index.php/topic,5079.msg24483.html#msg24483  Is there another newer way to fail gracefully when tags used in the rename command are missing? Or is just creating a hierarchy of possible naming structures in the command the "right way"

This is a good way, but there are alternatives... From the application documentation:

            If a specified tag does not exist, a minor warning is issued and
            the line with the missing tag is not printed.  However, the -f
            option may be used to set the value of missing tags to '-' (but
            this may be configured via the MissingTagValue API option), or the
            -m option may be used to ignore minor warnings and leave the
            missing values empty.


Quote
I still have not figured out why DATEFMT is not working though.

I just tried and the second command works for me with ExifTool 11.34.  What version of ExifTool are you using?

- 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 ($).

effgee

  • Newbie
  • *
  • Posts: 6
Re: Really struggling to get my exiftool command right, please help.
« Reply #7 on: April 06, 2019, 12:11:02 PM »


Hi thanks for the heads up regarding missing tags documentation.

To answer your question

➜  _ExifToolSorter exiftool -ver
10.40

Using the version packaged in Debian 9, its been years since I used CPAN and have forgotten how to use it although I'm guessing that is the best way to get the most current version?


EDIT: Updated from CPAN,  and regarding DATEFMT, that solved it. Seems to be working now! Thank you Phil!
« Last Edit: April 06, 2019, 12:26:00 PM by effgee »

nextra

  • Newbie
  • *
  • Posts: 1
Re: Really struggling to get my exiftool command right, please help.
« Reply #8 on: April 24, 2019, 08:28:46 AM »
Greetings to everyone!

Although not exactly here, but for me too I should do a little better for my command.
Does this require a new thread?

I need some help.
I would like to put together the following folder structure, but it has not yet been fully compiled.
Camera / year / year month / pictures
Camera / videos / foo.avi (%F_%T).avi
I brought the first one.
Code: [Select]
exiftool -r -progress -d '%Y/%Y-%m/IMG_%Y-%m-%d_%H:%M:%S%%-c.%%le' '-filename<${make}_${model}/${datetimeoriginal}' $DIR
But I don't know how to move  the movies?
exiftool version: 10.45

I've tried this command:  (I know that this, does not do it) Just tried.
Code: [Select]
exiftool '-testname<./${mimetype;$_=/video/ ? "Videos" : "Photographs"}/$createdate.%le' -d "%Y/%Y-%m/%Y%m%d_%H%M%S" .
Mimetype doesn't respond to things. Only if I put the extension specifically.
-ext+ avi - not work
-ext avi -ext jpg work.

But I still don't know, how to solve it make movies go to the camera / videos folder specified name.
Thanks in advance.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14554
    • ExifTool Home Page
Re: Really struggling to get my exiftool command right, please help.
« Reply #9 on: April 24, 2019, 08:59:12 AM »
I think this is FAQ 16.

- 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 ($).