Need to remove some characters from result

Started by tlm2408, August 09, 2018, 07:08:54 PM

Previous topic - Next topic

tlm2408

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

Stephen Marsh

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!

StarGeek

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

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"
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Stephen Marsh

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.

tlm2408

Thank you for your time guys. Thank you StarGeek that works great, I'm gonna have to learn regex I think  :)