Split Path New Line Issue

Hello

I'm trying to create a macro to convert a png image file selected in finder into a jpeg.
I have the macro mostly working.
I want to check that the file extension of the selected file is .png

To do this I'm using Split Path.
Initially I tried checking if the "Extention to:" field was equal to png, but that didn't work. So to help me figure out why, I used an alert to display the values of all the Split Path fields to the screen, as shown in the screenshot.
Split Path seems to be adding an extra newline character after the file extension, in both its 'File name to:' and 'Extension to:' fields.

Could someone explain this behaviour? The same thing happens with all file extensions, not just png.

(I know I can work around this problem, by checking if the extension contains png rather than is equal to it.)

I can't replicate that behaviour. Could you upload the actual Macro?

By "equal" do you mean "=" as that will only evaluate a Numeric Calculation. Instead of "=" use "is" which checks for text.

Thanks Zabobon.

It was 'is' I was using, not =.

convert to jpeg v2.kmmacros (7.3 KB)

I've attached my current version of the macro. It doesn't test for the file extension.

You've managed to put a linefeed character after your %PathFileName% token:

Notice that the action's name doesn't show the closing quotes and how a triple-click has selected the whole box. After deleting the linefeed:

...the action's name looks "proper" and a triple-click only selects the token.

4 Likes

That's great @Nige_S ! Thanks, that's fixed it. I didn't even know that was possible.