Moving images into subdirectories not working

Started by philipp_hb, May 31, 2018, 11:37:10 AM

Previous topic - Next topic

philipp_hb

I am trying to move images based on the contents of the Subject tag, with the code provided below.
All images that contain a 1: within the tag are moved into a subdirectory named according to the species name following the 1:. However, images that do not have the 1: in their tag are not being moved to a 'Empty' directory, but are moved into the image_sorted directory.

exiftool -m -r '-Filename=../Data/image_sorted/Empty/%f%+c%E' '-Filename<../Data/image_sorted/${Subject;$_=undef if not s/.*(?:^|, )1: (.*?)(,|$).*/$1/}/%f%+c%E' ../Data/image_raw


I am using relative pathways, does this have an influence?
Any ideas?

Phil Harvey

The way you have it, the images that don't match are being moved into a "../Data/image_sorted/Empty" directory. Did you want just "../Data/Empty" instead?

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

philipp_hb

Thanks for the quick reply.

No I would like them to be moved into a subdirectory within the 'image_sorted' directory. However, currently the images are being moved into "../Data/image_sorted", and not into "../Data/image_sorted/Empty"

Therefore, I currently have to use the following line of code:
mv ../Data/image_sorted/*.jpg ../Data/image_sorted/Empty

Phil Harvey

Ah.  I see.

The problem is the -m option, which ignores missing tag values and replaces them with an empty string.

Remove the -m and it should work for you.

Buried deep within the documentation:

            the -m option may be used to ignore minor warnings and leave
            the missing values empty.


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

StarGeek

Original post on StackOverflow.

Glad to see the problem get fixed, philipp_hb.  I didn't realize that the -m option would do that in this case.  You'll get the minor error response I mentioned but it can be ignored.

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

philipp_hb

Thank you both for the help!

I've instead added 2> /dev/null at the end of the command to suppress the warning messages.

However, I've now encountered another problem, where if I add the -o tag (to copy instead of moving the images), the empty images (missing the 1:) are not being copied at all, whereas all other images are.

Again, appreciate any input!

Phil Harvey

Did you forget to give -o an argument?  Use "-o ."

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

philipp_hb

That was it! Could you explain what the '.' argument is for?

Cheers,
Philipp

Phil Harvey

-o requires an argument which is a file name, directory name, or filename/directory format string.  But you are overriding the output directory by specifying a directory when you set the FileName tag, so anything would do here ("." is just convenient).  See Example 11 here.

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