Author Topic: Using parent directory name as -Title within jpg  (Read 40 times)

nuttybacon

  • Newbie
  • *
  • Posts: 2
Using parent directory name as -Title within jpg
« on: October 11, 2019, 11:08:01 AM »
Hi,

I want to add a title to my pictures based on the folder name they reside excluding any other parent folders.

If I run this

EXIFTOOL -r "-Title<${directory" "C:\Temp\Christmas 2018"

the meta title meta data is added as 'C:\Temp\Christmas 2018'

I only want to add Christmas 2018

I have a Picture structure like this (below is just examples)

I want to run this exif tool command on the parent 'Pictures' folder. I don't want to run on every single folder.

so all pictures within Holiday Cyprus (picture 111 and picture 222) will be given a title of Holiday Cyprus and not c:\pictures\holidays\Holiday Cyprus and so on. Hope this makes sense.

Pictures
-Holidays
--Holiday Cyprus#
---picture 111.jpg
---picture222.jpg
--Holiday Italy
---picture 333.jpg
---picture 444.jpg
-Christmas
--Christmas 2018
---picture 555.jpg
---picture 666.jpg
--Christmas 2017
---picture 777.jpg
---picture 888.jpg


Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 15115
    • ExifTool Home Page
Re: Using parent directory name as -Title within jpg
« Reply #1 on: October 11, 2019, 11:11:44 AM »
Try this:

exiftool -r "-title<${directory;s(.*/)()}" DIR

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

nuttybacon

  • Newbie
  • *
  • Posts: 2
Re: Using parent directory name as -Title within jpg
« Reply #2 on: October 12, 2019, 06:48:48 PM »
Thanks. Worked a treat.