News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Really struggling to get my exiftool command right, please help.

Started by effgee, April 06, 2019, 06:39:28 AM

Previous topic - Next topic

effgee

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.



Phil Harvey

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

effgee

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

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

effgee

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

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: https://exiftool.org/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

Phil Harvey

Quote from: effgee on April 06, 2019, 10:01:17 AM
EDIT 2: Ok, I figured out the solution regarding missing tags and failing to rename. I found the solution here: https://exiftool.org/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.


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

effgee



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!

nextra

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.
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.
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

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