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

Stephen Marsh

  • Sr. Member
  • ****
  • Posts: 221
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


http://owl.phy.queensu.ca/~phil/exiftool/#tagnames

http://owl.phy.queensu.ca/~phil/exiftool/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: 14895
    • 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: 221
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: 221
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: 221
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://sno.phy.queensu.ca/~phil/exiftool/exiftool_pod.html#execute-NUM

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14895
    • 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 ($).