ExifTool Forum

ExifTool => Newbies => Topic started by: tlm2408 on August 09, 2018, 07:08:54 PM

Title: Need to remove some characters from result
Post by: tlm2408 on August 09, 2018, 07:08:54 PM
This is running from a batch file in Windows.

exiftool.exe -api filter="s/ \(approx\)//" -AudioBitrate -FileName -Directory -Comment -Artist -Title -Album -Duration -j -r -ext mp3 -ext flac -progress "C:\Audio" >>"MusicSearch temp.js"

This is all working great.
At the moment -Directory is returning a full path as it should eg: C:/Audio/Artist/Album....
I need to loose the C:/Audio/ part, so that I end up with Artist/Album...

Is this possible?

Also not so important, but I would like to change each "/" to " - "

Any help is greatly apprieciated
Title: Re: Need to remove some characters from result
Post by: Stephen Marsh on August 10, 2018, 08:45:44 AM
I am not understanding 100%...

The regex should be simple enough

/^C:\/Audio\///


;s/^C:\/Audio\///


However I doubt that the syntax is correct...

Similar for the forward slashes to hyphens:

/\//-/g

However again, what I am not understanding probably invalidates what I just wrote!

Looking forward to see what the answer really is!
Title: Re: Need to remove some characters from result
Post by: StarGeek on August 10, 2018, 01:19:57 PM
You pretty much have it, Stephen, though I probably would use tr/\//-/ instead, not that savings would be that measurable.

The question is whether replacing slashes is going to have an affect on any of the other tags.  For example, AC/DC would become AC-DC and Love Without Tragedy / Mother Mary by Rihanna would become Love Without Tragedy - Mother Mary.  This could be solved using the hashtag # option of the -n option (https://exiftool.org/exiftool_pod.html#n---printConv)

So, I'd say try this out and see if it needs refining:
exiftool.exe -api filter="s/ \(approx\)//;s/^C:\/Audio\///;tr/\//-/" -AudioBitrate -FileName -Directory -Comment# -Artist# -Title# -Album# -Duration -j -r -ext mp3 -ext flac -progress "C:\Audio" >>"MusicSearch temp.js"
Title: Re: Need to remove some characters from result
Post by: Stephen Marsh on August 10, 2018, 09:58:05 PM
Thanks StarGeek! As I said, the syntax would have killed me – not the regex itself so much, but tying the regex it into the full command. I thought that one would need to link the regex directly to the Directory tag, rather than in the expression before the tags.
Title: Re: Need to remove some characters from result
Post by: tlm2408 on August 11, 2018, 08:55:46 PM
Thank you for your time guys. Thank you StarGeek that works great, I'm gonna have to learn regex I think  :)