News:

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

Main Menu

Copy parts of filename into tag

Started by thimplicity, November 12, 2017, 09:58:56 AM

Previous topic - Next topic

StarGeek

-d "%Y##%B" -Sep "##" "-keywords+<TAG"

You'll have to figure out what date tag you want to use but DateTimeOriginal is what I would use on images from a camera.
* 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).

thimplicity

Quote from: StarGeek on November 20, 2017, 09:36:12 PM
-d "%Y##%B" -Sep "##" "-keywords+<TAG"

You'll have to figure out what date tag you want to use but DateTimeOriginal is what I would use on images from a camera.

This works great. I have done some adjustments as you explained in earlier posts and it works great. Thanks!

Quote from: StarGeek on November 20, 2017, 08:31:11 PM
To add the last three parent directories, try this:
-sep "##" "-Keywords+<${directory;s/.*\/([^\/]+?)\/([^\/]+?)\/([^\/]+?$)/$1##$2##$3/}"

This will fail if there aren't at least three parents

This does not work for me, or I am doing something wrong. It only adds one tag called "." to the file. I tried it with the file name "IMG_3018.JPG" in the directory "C:\Temp\PicturesNEW\STRUCTURE\Test event\test year\test sub event"

StarGeek

Quote from: thimplicity on November 21, 2017, 08:41:45 AM
This does not work for me, or I am doing something wrong. It only adds one tag called "." to the file. I tried it with the file name "IMG_3018.JPG" in the directory "C:\Temp\PicturesNEW\STRUCTURE\Test event\test year\test sub event"

You did nothing wrong, just a difference in style.  You had CD'ed to the "test sub event" directory (or something like that), correct?   I tend not to change directories and copy/paste my target directory into my commands.

Change Directory to FilePath and it should be good.  Directory is based upon what is entered on the command line.  FilePath is the absolute path for the file.
* 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).

thimplicity

Quote from: StarGeek on November 21, 2017, 10:16:27 AM
Quote from: thimplicity on November 21, 2017, 08:41:45 AM
This does not work for me, or I am doing something wrong. It only adds one tag called "." to the file. I tried it with the file name "IMG_3018.JPG" in the directory "C:\Temp\PicturesNEW\STRUCTURE\Test event\test year\test sub event"

You did nothing wrong, just a difference in style.  You had CD'ed to the "test sub event" directory (or something like that), correct?   I tend not to change directories and copy/paste my target directory into my commands.

Change Directory to FilePath and it should be good.  Directory is based upon what is entered on the command line.  FilePath is the absolute path for the file.

Thanks, it did not work with filepath (this just adds one tag with the complete path), but I changed my way to your way of working, which means adding the directory to the command. Now it works!

thimplicity

I have now modified the commands and it works. I have now created to structure, and I am am in the process of tagging all my photos

This is AWESOME - thank you so much for your help!

Is there any way to automate this whole process? Currently my steps would be as follows:


  • Copy photos from Onedrive to HDD (they are uploaded from our iPhones)
  • Deduplicate with Vispics
  • Add location information and geo tags with Geosetter
  • Move into respective folder
  • Add folder tags and year tags with Exiftool
  • Manually tag people like myself
  • Upload

Thanks again :)

StarGeek

Quote from: thimplicity on November 21, 2017, 10:26:08 AM
Thanks, it did not work with filepath (this just adds one tag with the complete path)

Ooops, sorry.  Filepath includes the filename at the end, which would require a change to the regex.
-sep "##" "-keywords+<${filepath;s/.*\/([^\/]+?)\/([^\/]+?)\/([^\/]+?)\/[^\/]+?$/$1##$2##$3/}"

Alternatively, since that's getting messy and hard to understand
-sep "##" "-keywords+<${filepath;my @a=split('/',$_);$_=join('##',@a[-4..-2])}"

Breakdown:
my @a=split('/',$_) - splits Filepath into separate strings at every slash and assigns the strings to array @a
$_=join('##',@a[-4..-2]) - Joins the 4th from the end up to the second from the end entries in the array into a string again, but separated by '##'
* 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).

StarGeek

I'm not sure there's much there that can be automated.  I'm not familiar with Vispics but when it comes to duplicate removal, I'm always careful as I've seen some fuzzy match algorithms be way off.  Steps 3, 4, and 6 seem to manual, no matter what.  1, 5, and 7 could be automated, but since there are manual steps in between, seems hard to do.  Batch files would help so you don't have to redo the commands everytime.
* 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).

thimplicity

I have some folders that contain images with and without GPS coordinates. Is there a way to extrapolate the coordinates to the ones missing them based on the date taken?

thanks again

Alan Clifford

If the photographs are 6 months apart and in different parts of the world, then no.

But assuming the photos in the directory are related in time and space, then you should be able to do it with exiftool.  My first though is to create a trackfile, with exiftool, from the photos with gps data and then use exiftool to interpolate positions from that trackfile and put them into the other photos.

There might be a more integrated way but it's not something I do so I don't know.

thimplicity

#24
Quote from: Alan Clifford on November 22, 2017, 10:26:23 AM
If the photographs are 6 months apart and in different parts of the world, then no.

But assuming the photos in the directory are related in time and space, then you should be able to do it with exiftool.  My first though is to create a trackfile, with exiftool, from the photos with gps data and then use exiftool to interpolate positions from that trackfile and put them into the other photos.

There might be a more integrated way but it's not something I do so I don't know.

The photos are definitely related (all from one vacation), sometimes I have photos with coordinates and some without on the same day.

Do you know if this can be done with Geosetter? How can I create such a trackfile? According to the Geosetter help you can do that (Export to GPX file), but I cannot find the entry anywhere in the menu

Alan Clifford

Have a look at https://exiftool.org/geotag.html#Reverse and look at the Inverse Geotagging section.

There is an example of creating a gpx file and geosetter understands gpx. 

By the way, Geosetter uses exiftool.

thimplicity

I had to install a newer version of Geosetter for the export functionality to be available

now it works - thanks again

Shantastic

Quote from: StarGeek on November 20, 2017, 08:31:11 PM

QuoteI would also like to add the parent folder as well as two further parent folder names' as tags.

To add the last three parent directories, try this:
-sep "##" "-Keywords+<${directory;s/.*\/([^\/]+?)\/([^\/]+?)\/([^\/]+?$)/$1##$2##$3/}"

This will fail if there aren't at least three parents

Hello! I'm new and late to the party, but this thread has been instrumental in helping me get where I'm trying to go.  I'm trying to copy my directory structure into keywords so that I can redo my photo organization to sort by year/month folders instead of topic/subtopic/etc folders.  I didn't want to lose all the event/topic info in the process.

The suggestion above wouldn't work for me because I don't have a predictable number of subfolder levels.  I figured out I can use the separator command instead of the regex to parse the slashes out of the directory name, like so:

-r -P -sep "/" "-subject+<$Directory" <dir>
-r -P -subject-="D:" -subject-="Photos" <dir>


The second line is to remove the parent folders that I don't need as keywords on every file.  I'm using the -subject field rather than the -keywords field because that's the one with which Lightroom seems happier.

I haven't yet taken the plunge to run this on the parent directory, but so far it's working in my testing!

Thanks to everyone for the helpful, detailed discussion here.

Hayo Baan

Smart! But this should be easily doable in one go with a simple regular expressions as well. E.g.
-r -P -sep "/" "-Subject+<${directory;s/^D:\/Photos\///;}"

This strips D:/Photos/ from the directory and then uses all remaining subdirectories as keywords.
Hayo Baan – Photography
Web: www.hayobaan.nl