Author Topic: Remove _ and - from tags when writing based on file name  (Read 1188 times)

avalut

  • Jr. Member
  • **
  • Posts: 26
Remove _ and - from tags when writing based on file name
« on: January 02, 2019, 05:54:22 PM »
Hi,

I have been slowly getting there with adding meta data to a load of images in a folder.

Say first file name is:

Lot_439_1-Heathrow-T1-Aviation-Glass-Desk.jpg

I can with this command
perl c:\windows\exiftool.pl -P -r "-title<${filename;s/\.jpg$//i}" -sep " " -ext jpg C:\Users\Andrew\Desktop\testimage

Write Lot_439_1-Heathrow-T1-Aviation-Glass-Desk to the title tag.

I would like to remove to write the title as below:

Lot 439 Heathrow T1 Aviation Glass Desk

I then need to do the same for the Subject tag and comments tag.

Also then apply a fixed name "Auctioneersvault Ltd" to the Copywrite and Author tag

Once I get this working I will attempt to call it from within a UBot exe, which currently downloads all the images and names them on download from 1.jpg etc to the above.

sorry if I asked 3 things at once.

Andrew

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2909
Re: Remove _ and - from tags when writing based on file name
« Reply #1 on: January 02, 2019, 06:24:37 PM »
You can add s/[-_]/ /g to replace all dashes and underscores with spaces.  For example, ${filename;s/\.jpg$//i;s/[-_]/ /g}
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

avalut

  • Jr. Member
  • **
  • Posts: 26
Re: Remove _ and - from tags when writing based on file name
« Reply #2 on: January 02, 2019, 06:30:31 PM »
I tried this command and it didn't remove them ?

perl c:\windows\exiftool.pl -P -r "-subject<${filename;s/[-_]/ /g/\.jpg$//i}" -sep " " -ext jpg C:\Users\Andrew\Desktop\testimage

avalut

  • Jr. Member
  • **
  • Posts: 26
Re: Remove _ and - from tags when writing based on file name
« Reply #3 on: January 02, 2019, 06:34:40 PM »
Sorry, going blind tried
perl c:\windows\exiftool.pl -P -r "-subject<${filename;s/\.jpg$//i;s/[-_]/ /g}" -sep " " -ext jpg C:\Users\Andrew\Desktop\testimage

its replacing the spaces with a ;and a space

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2909
Re: Remove _ and - from tags when writing based on file name
« Reply #4 on: January 02, 2019, 07:12:24 PM »
I just copy/pasted your command and it worked, though maybe not how you want it.  Separating on space puts Lot, 439, and 1 as individual keywords, where I think you would actually want "Lot 439 1" as a single keyword.

Code: [Select]
C:\>exiftool -overwrite_original -P -r "-subject<${filename;s/\.jpg$//i;s/[-_]/ /g}" -sep " " -ext jpg "Y:\!temp\bb\Lot_439_1-Heathrow-T1-Aviation-Glass-Desk.jpg"
    1 image files updated

C:\>exiftool -g1 -a -s -subject "Y:\!temp\bb\Lot_439_1-Heathrow-T1-Aviation-Glass-Desk.jpg"
---- XMP-dc ----
Subject                         : Lot, 439, 1, Heathrow, T1, Aviation, Glass, Desk
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

avalut

  • Jr. Member
  • **
  • Posts: 26
Re: Remove _ and - from tags when writing based on file name
« Reply #5 on: January 02, 2019, 07:20:40 PM »
I need it to remove the , its putting in then its how I am after it.

so
Lot, 439, 1, Heathrow, T1, Aviation, Glass, Desk

To become
Lot 439 1 Heathrow T1 Aviation Glass Desk

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 15346
    • ExifTool Home Page
Re: Remove _ and - from tags when writing based on file name
« Reply #6 on: January 02, 2019, 09:10:17 PM »
The ", " is just the default separator for list items.  XMP:Subject is a list-type tag, and list items are stored individually.  You can add -sep " " to the extraction command to display them with just spaces between them.

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

avalut

  • Jr. Member
  • **
  • Posts: 26
Re: Remove _ and - from tags when writing based on file name
« Reply #7 on: January 03, 2019, 04:08:38 AM »
Hi Phil,
Slightly confused as it has the -sep " " command in. do I need to add it again in the string?

Stephen Marsh

  • Sr. Member
  • ****
  • Posts: 223
Re: Remove _ and - from tags when writing based on file name
« Reply #8 on: January 03, 2019, 06:21:20 AM »
avalut, I don’t wish to confuse things, however your request interested me…

For the first part to add the filename to the title removing underscore/hyphen/extension, I would offer the following method of combining two regular expressions together:

exiftool "-title<${filename;s/\.[^\.]+$//;s/[-|_]/ /g}" -r DIR

However I think that you will need to clarify the exact fields that you wish to write to for the Copyright and Author tag. The easiest way is to use the exiftool -a -G1 -s FILE command to list the writable tag names on a file that you know has this data.

EDIT: Ah, I now see that StarGeek has already offered a similar approach!
« Last Edit: January 03, 2019, 07:15:57 AM by Stephen Marsh »

avalut

  • Jr. Member
  • **
  • Posts: 26
Re: Remove _ and - from tags when writing based on file name
« Reply #9 on: January 03, 2019, 06:34:04 AM »
Hi Stephen,
The files have the following fields

Artist
Creator
Subject
Title
Copyright

avalut

  • Jr. Member
  • **
  • Posts: 26
Re: Remove _ and - from tags when writing based on file name
« Reply #10 on: January 03, 2019, 06:42:50 AM »
This works great:
perl c:\windows\exiftool.pl -P -r "-title<${filename;s/\.[^\.]+$//;s/[-|_]/ /g}" -r -sep " " -ext jpg C:\Users\Andrew\Desktop\testimage

and does what I want.

I cannot follow why when I change -title to -subject or comments to write the same data it just says "the system cannot find the file specified.

What am I missing?

Stephen Marsh

  • Sr. Member
  • ****
  • Posts: 223
Re: Remove _ and - from tags when writing based on file name
« Reply #11 on: January 03, 2019, 06:45:39 AM »
I was hoping for the full tag and value, such as:

Code: [Select]
[IFD0]          Artist                          : Auctioneersvault Ltd
[IFD0]          Copyright                       : Auctioneersvault Ltd
[XMP-dc]        Rights                          : Auctioneersvault Ltd
[XMP-xmpRights] Marked                          : True
[Photoshop]     CopyrightFlag                   : True
[IPTC]          By-line                         : Auctioneersvault Ltd
[IPTC]          CopyrightNotice                 : Auctioneersvault Ltd
[XMP-dc]        Creator                         : Auctioneersvault Ltd
[XMP-dc]        Rights                          : Auctioneersvault Ltd
[XMP-photoshop] AuthorsPosition                 : Lot 439 1 Heathrow T1 Aviation Glass Desk
[IPTC]          By-lineTitle                    : Lot 439 1 Heathrow T1 Aviation G
« Last Edit: January 03, 2019, 06:58:51 AM by Stephen Marsh »

Stephen Marsh

  • Sr. Member
  • ****
  • Posts: 223
Re: Remove _ and - from tags when writing based on file name
« Reply #12 on: January 03, 2019, 06:47:30 AM »
Could it be something as simple as:

perl c:\windows\exiftool.pl -P -r "-title<${filename;s/\.[^\.]+$//;s/[-|_]/ /g}" -r -sep " " -ext jpg C:\Users\Andrew\Desktop\testimage

vs.

perl c:\windows\exiftool.pl -P -r "-title<${filename;s/\.[^\.]+$//;s/[-|_]/ /g}" -r -sep " " -ext jpg C:\Users\Andrew\Desktop\testimage.jpg

Which does not answer why one works and the other does not…

I would remove the duplicate -r recursive command, I generally now put it directly before the target file/directory.

avalut

  • Jr. Member
  • **
  • Posts: 26
Re: Remove _ and - from tags when writing based on file name
« Reply #13 on: January 03, 2019, 06:53:56 AM »
testimage is the folder, I am trying to change about 2600 images (but only one currently in testimage) if that makes sense

avalut

  • Jr. Member
  • **
  • Posts: 26
Re: Remove _ and - from tags when writing based on file name
« Reply #14 on: January 03, 2019, 06:55:15 AM »
its also the same as another question I posted - one works and the other not as

perl c:\windows\exiftool.pl -artist="Phil Harvey" -copyright="2011 Phil Harvey" C:\Users\Andrew\Desktop\testimage

and it writes correctly to the file but if I change it to

perl c:\windows\exiftool.pl -artist="Silverstone Auctions" -copyright="2019 Silverstone Auctions" C:\Users\Andrew\Desktop\testimage

it come up with an error file not found, both are text fields and apart from more characters there is no change om what the command is asking unless I am missing something.

so something must be causing one thing to work and another not, what I have no idea.

avalut

  • Jr. Member
  • **
  • Posts: 26
Re: Remove _ and - from tags when writing based on file name
« Reply #15 on: January 03, 2019, 07:02:15 AM »
This is what it is doing
======== C:/Users/Andrew/Desktop/testimage/Lot_439_1-Heathrow-T1-Aviation-Glass-
Desk.jpg
ExifTool Version Number         : 11.23
File Name                       : Lot_439_1-Heathrow-T1-Aviation-Glass-Desk.jpg
Directory                       : C:/Users/Andrew/Desktop/testimage
File Size                       : 234 kB
File Modification Date/Time     : 2019:01:03 03:22:26-08:00
File Access Date/Time           : 2019:01:03 03:22:26-08:00
File Creation Date/Time         : 2019:01:02 12:22:33-08:00
File Permissions                : rw-rw-rw-
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Exif Byte Order                 : Big-endian (Motorola, MM)
X Resolution                    : 96
Y Resolution                    : 96
Resolution Unit                 : inches
Artist                          : Phil Harvey
Y Cb Cr Positioning             : Centered
Copyright                       : 2011 Phil Harvey
XMP Toolkit                     : Image::ExifTool 11.23
Creator                         : Creator
Subject                         : Lot_439_1-Heathrow-T1-Aviation-Glass-Desk
Title                           : Lot 439 1 Heathrow T1 Aviation Glass Desk
Comment                         : CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), de
fault quality.
Image Width                     : 1000
Image Height                    : 750
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Image Size                      : 1000x750
Megapixels                      : 0.750

Stephen Marsh

  • Sr. Member
  • ****
  • Posts: 223
Re: Remove _ and - from tags when writing based on file name
« Reply #16 on: January 03, 2019, 07:05:09 AM »
Rather than using tag shortcuts, perhaps try the full form, such as:

-IFD0:Artist="Auctioneersvault Ltd"

Rather than:

-artist="Auctioneersvault Ltd"

Again, not an answer, just clutching at straws...

Stephen Marsh

  • Sr. Member
  • ****
  • Posts: 223
Re: Remove _ and - from tags when writing based on file name
« Reply #17 on: January 03, 2019, 07:07:15 AM »
Please try:

exiftool -a -G1 -s FILE

Rather than:

exiftool FILE

To receive the unambiguous full tag name/group etc.

avalut

  • Jr. Member
  • **
  • Posts: 26
Re: Remove _ and - from tags when writing based on file name
« Reply #18 on: January 03, 2019, 07:21:32 AM »
ahahahahhahahhahahahha

Bloody Mac was producing a funny " when pasted in to my windows VPS.

Just got it to accept the artist fine so will try again with the others.
about 5 hours of going mad..

Don't copy and paste from a Mac to a windows machine.

avalut

  • Jr. Member
  • **
  • Posts: 26
Re: Remove _ and - from tags when writing based on file name
« Reply #19 on: January 03, 2019, 07:50:42 AM »
Ok so now have it working with these 3 commands

perl c:\windows\exiftool.pl -artist="Silverstone Auction" -copyright="2019 Silverstone Auction" C:\Users\Andrew\Desktop\testimage

perl c:\windows\exiftool.pl -P -r "-title<${filename;s/\.[^\.]+$//;s/[-|_]/ /g}" -r -sep " " -ext jpg C:\Users\Andrew\Desktop\testimage

perl c:\windows\exiftool.pl -subject="Silverstone Auction AUTOSPORT INTERNATIONAL SHOW SALE 12th January 2019" C:\Users\Andrew\Desktop\testimage

The subject tag writes to the Tags section and subject is still blank.
Cannot write to comments tag - says it cannot be written to.

So how would I combine the 3 above or is it best to do one at a time?

Is there a command to create an Alt Tag for SEO that would be the Title tag?

Thanks
Andrew

Stephen Marsh

  • Sr. Member
  • ****
  • Posts: 223
Re: Remove _ and - from tags when writing based on file name
« Reply #20 on: January 03, 2019, 08:05:28 AM »
Again

exiftool -a -G1 -s FILE

or

exiftool -a -G1 -s -r DIR

is your friend!

Ensure the test file has the metadata that you wish to write.

“Subject" is actually -XMP-dc:Subject which is the modern replacement of the legacy “Keyword” tag  -IPTC:Keyword.

I believe you are looking for:

-IFD0:XPSubject if you are expecting the MS Windows “Subject” field viewed under “properties”…


This is why it is helpful to use full tag names rather than shortcuts!
« Last Edit: January 03, 2019, 08:34:12 AM by Stephen Marsh »

avalut

  • Jr. Member
  • **
  • Posts: 26
Re: Remove _ and - from tags when writing based on file name
« Reply #21 on: January 03, 2019, 08:12:48 AM »
The alt Tag is not in the current file so has to be added - presume this is the issue.

Stephen Marsh

  • Sr. Member
  • ****
  • Posts: 223
Re: Remove _ and - from tags when writing based on file name
« Reply #22 on: January 03, 2019, 08:23:04 AM »
I have not tested, however if all of the following tags were correct, then it should just be simple matter of stringing the arguments together:

perl c:\windows\exiftool.pl -ext jpg -P -artist="Silverstone Auction" -copyright="2019 Silverstone Auction" "-title<${filename;s/\.[^\.]+$//;s/[-|_]/ /g}" -sep " " -subject="Silverstone Auction AUTOSPORT INTERNATIONAL SHOW SALE 12th January 2019" -r "C:\Users\Andrew\Desktop\testimage"

If run from a batch file in Windows, then you could put the arguments on separate lines which would help make it easier to read!

However, again I would suggest that you use the full tag names rather than shortcut tags so that the metadata write is to the correct field, not a similar named but different field.

avalut

  • Jr. Member
  • **
  • Posts: 26
Re: Remove _ and - from tags when writing based on file name
« Reply #23 on: January 03, 2019, 08:24:37 AM »
understood and many thanks.

avalut

  • Jr. Member
  • **
  • Posts: 26
Re: Remove _ and - from tags when writing based on file name
« Reply #24 on: January 03, 2019, 09:42:48 AM »
Stephen,

I have finally managed to get 90% of the fields with data.
Where do I find the "full tag names"

I want to populate the comments tag in windows preview.

Then I think I am as good as its going to be.

avalut

  • Jr. Member
  • **
  • Posts: 26
Re: Remove _ and - from tags when writing based on file name
« Reply #25 on: January 03, 2019, 09:48:45 AM »
Ok found where they are https://exiftool.org/TagNames/EXIF.html
that so all my actions are below and it doesn't like me combining them for some reason so will just action one at a time and if called from Ubot it should just move down them.


perl c:\windows\exiftool.pl -P -r "-title<${filename;s/\.[^\.]+$ //;s/[-|_]/ /g}" -r -sep " " -ext jpg C:\Users\Andrew\Desktop\testimage
perl c:\windows\exiftool.pl -artist="Silverstone Auctions" -copyright="2019 Silverstone Auctions" C:\Users\Andrew\Desktop\testimage
perl c:\windows\exiftool.pl -subject="Silverstone Auctions AUTOSPORT INTERNATIONAL SHOW SALE 12th January 2019" C:\Users\Andrew\Desktop\testimage


perl c:\windows\exiftool.pl -creator="Silverstone Auctions" C:\Users\Andrew\Desktop\testimage

perl c:\windows\exiftool.pl -P -r "-description<${filename;s/\.[^\.]+$ //;s/[-|_]/ /g}" -r -sep " " -ext jpg C:\Users\Andrew\Desktop\testimage

perl c:\windows\exiftool.pl -P -r "-IFD0:XPSubject<${filename;s/\.[^\.]+$ //;s/[-|_]/ /g}" -r -sep " " -ext jpg C:\Users\Andrew\Desktop\testimage

perl c:\windows\exiftool.pl -P -r "-IFD0:XPComment<${filename;s/\.[^\.]+$ //;s/[-|_]/ /g}" -r -sep " " -ext jpg C:\Users\Andrew\Desktop\testimage

Still don't have the alt Tag element but think that should give the search engines enough info.

Many thanks again.
Andrew

avalut

  • Jr. Member
  • **
  • Posts: 26
Re: Remove _ and - from tags when writing based on file name
« Reply #26 on: January 03, 2019, 09:59:51 AM »
Stephen,

This command works better from reading the description of the lot
perl c:\windows\exiftool.pl -P -r "-title<${filename;s/\.[^\.]+$ //;s/[-]/ /g}" -r -sep " " -ext jpg C:\Users\Andrew\Desktop\testimage

So I have dropped the _
so we get say Lot_101_3 a big blue badge

The reason there are a number of images per lot so need to make that obvious.

Is there a way to remove only the first _ and substitute with a space rather than both it would then read
Lot 101_3 a big blue badge

Which would be exactly what I was after.

Andrew

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 15346
    • ExifTool Home Page
Re: Remove _ and - from tags when writing based on file name
« Reply #27 on: January 03, 2019, 10:31:22 AM »
Hi Andrew,

Try this to change the first underline to a space: "-title<${filename;s/\.[^\.]+$ //;s/[-]/ /g;s/_/ /}"

You should be able to combine all your commands into 2 commands.  The complication is that the -sep " " will write each word separately when writing a list-type tag, so you need one command with -sep " " and one without so that the words don't get written as separate items when writing tags like XMP:Subject.

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

avalut

  • Jr. Member
  • **
  • Posts: 26
Re: Remove _ and - from tags when writing based on file name
« Reply #28 on: January 03, 2019, 10:47:15 AM »
Hi Phil,

That has worked perfect   - thank you.
I will look at trying to combine, and see how I get on.

I was looking at this post from a while back on the Alt tag is this method described at the end still valid
https://exiftool.org/forum/index.php?topic=6433.0

Finally getting my head around the tool, after spending today and last night on it.

I do like pushing things so will after I have this sorted move on to geo-location tagging and see how much of a mess I get in.

Best regards Andrew


StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2909
Re: Remove _ and - from tags when writing based on file name
« Reply #29 on: January 03, 2019, 12:04:51 PM »
I was looking at this post from a while back on the Alt tag is this method described at the end still valid
https://exiftool.org/forum/index.php?topic=6433.0

It's important to note that answer has to do with what data the Zenfolio website would read.  If you're not working on Zenfolio, then it probably doesn't apply.

As to whether it still works or not would require someone with access to Zenfolio to test.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

Stephen Marsh

  • Sr. Member
  • ****
  • Posts: 223
Re: Remove _ and - from tags when writing based on file name
« Reply #30 on: January 03, 2019, 05:21:37 PM »
Code: [Select]
Where do I find the "full tag names"

I use the following command on a file with known metadata populated in the target fields, in order to confirm which fields should be written in other files:

exiftool -a -G1 -s FILE


https://exiftool.org/index.html#tagnames

https://exiftool.org/faq.html#Q2

avalut

  • Jr. Member
  • **
  • Posts: 26
Re: Remove _ and - from tags when writing based on file name
« Reply #31 on: January 03, 2019, 07:00:26 PM »
for some reason the tags are still writing the jpg at the end of the descriptions with .jpg"

How do I delete that, I didn't notice it was still writing that element it was supposed to have removed that, I thought the -ext jpg woud remove it.

so all tags below have same issue ?

Thanks in advance.

Andrew

perl c:\windows\exiftool.pl -P -r "-title<${filename;s/\.[^\.]+$ //;s/[-]/ /g;s/_/ /}"" -r -sep " " -ext jpg C:\Users\Andrew\Desktop\SilverstoneImages
perl c:\windows\exiftool.pl -P -r "-description<${filename;s/\.[^\.]+$ //;s/[-]/ /g;s/_/ /}"" -r -sep " " -ext jpg C:\Users\Andrew\Desktop\SilverstoneImages
perl c:\windows\exiftool.pl -P -r "-IFD0:XPSubject<${filename;s/\.[^\.]+$ //;s/[-]/ /g;s/_/ /}"" -r -sep " " -ext jpg C:\Users\Andrew\Desktop\SilverstoneImages
perl c:\windows\exiftool.pl -P -r "-IFD0:XPComment<${filename;s/\.[^\.]+$ //;s/[-]/ /g;s/_/ /}"" -r -sep " " -ext jpg C:\Users\Andrew\Desktop\SilverstoneImages

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 15346
    • ExifTool Home Page
Re: Remove _ and - from tags when writing based on file name
« Reply #32 on: January 03, 2019, 07:02:23 PM »
It is this part that should remove the file extension:  s/\.[^\.]+$//

... but you have a space after the dollar sign that would stop this from working.

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

avalut

  • Jr. Member
  • **
  • Posts: 26
Re: Remove _ and - from tags when writing based on file name
« Reply #33 on: January 03, 2019, 07:06:27 PM »
Not using that site, was just looking at placing on a site, but maybe it will pick the tags up in any event.

avalut

  • Jr. Member
  • **
  • Posts: 26
Re: Remove _ and - from tags when writing based on file name
« Reply #34 on: January 03, 2019, 07:11:06 PM »
Hi Phil,

Bugger, didn't notice that.. ahahah that's why it was working and then didn't and I copied the error into the other tags.
Thank you, will fix it now.

Added the codes into Ubot and with their shell scrip plugin can run from it, so my program does now what I need as far as downloading the images/renaming and then applying all the tags from one program.

Thanks again
Andrew

avalut

  • Jr. Member
  • **
  • Posts: 26
Re: Remove _ and - from tags when writing based on file name
« Reply #35 on: January 03, 2019, 08:17:21 PM »
Hi Phil,

I am still getting an addtional " at the end of the description as per
Lot 117_1 Signed Mercedes Benz 300SE door"

There seems to be to many " in the string, which one is the odd one out ?
Andrew

Stephen Marsh

  • Sr. Member
  • ****
  • Posts: 223
Re: Remove _ and - from tags when writing based on file name
« Reply #36 on: January 03, 2019, 09:23:32 PM »
Remove the red "

perl c:\windows\exiftool.pl -P -r "-title<${filename;s/\.[^\.]+$//;s/[-]/ /g;s/_/ /}"" -r -sep " " -ext jpg C:\Users\Andrew\Desktop\SilverstoneImages
perl c:\windows\exiftool.pl -P -r "-description<${filename;s/\.[^\.]+$//;s/[-]/ /g;s/_/ /}"" -r -sep " " -ext jpg C:\Users\Andrew\Desktop\SilverstoneImages
perl c:\windows\exiftool.pl -P -r "-IFD0:XPSubject<${filename;s/\.[^\.]+$//;s/[-]/ /g;s/_/ /}"" -r -sep " " -ext jpg C:\Users\Andrew\Desktop\SilverstoneImages
perl c:\windows\exiftool.pl -P -r "-IFD0:XPComment<${filename;s/\.[^\.]+$//;s/[-]/ /g;s/_/ /}"" -r -sep " " -ext jpg C:\Users\Andrew\Desktop\SilverstoneImages

avalut

  • Jr. Member
  • **
  • Posts: 26
Re: Remove _ and - from tags when writing based on file name
« Reply #37 on: January 04, 2019, 05:12:25 AM »
Thank you Stephen.

Stephen Marsh

  • Sr. Member
  • ****
  • Posts: 223
Re: Remove _ and - from tags when writing based on file name
« Reply #38 on: January 04, 2019, 06:10:26 AM »
Did it work?

Stephen Marsh

  • Sr. Member
  • ****
  • Posts: 223
Re: Remove _ and - from tags when writing based on file name
« Reply #39 on: January 04, 2019, 07:06:57 AM »
You should be able to combine all your commands into 2 commands.  The complication is that the -sep " " will write each word separately when writing a list-type tag, so you need one command with -sep " " and one without so that the words don't get written as separate items when writing tags like XMP:Subject.

- Phil

Ah, thank you Phil, I did not consider the separator bit when I made the simple suggestion to combine the various arguments into one!

Thinking out loud, couldn’t one use the execute argument to string together two separate commands into a single command?

https://exiftool.org/exiftool_pod.html#execute-NUM

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 15346
    • ExifTool Home Page
Re: Remove _ and - from tags when writing based on file name
« Reply #40 on: January 04, 2019, 07:39:30 AM »
Thinking out loud, couldn’t one use the execute argument to string together two separate commands into a single command?

Yes.  I was would have mentioned this but I was worried about information overload.

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