Anyone know why "move or rename file" converts pdf to TextEdit?

So the problem has a solution, but has it really been "solved"?

Question to all. When you rename a file any other way than through KM macros, do you end all of your file names with .extension right in the name? I can answer that one. No you do not. I am not saying it is in fact a KM problem. Perhaps my Regex writing is to blame, but it would seem that the actual file extension would be protected from a regex meant to target just the name of a file. Thanks for the confirmation that I am not crazy :slight_smile:

You're right that KM isn't to blame - it's just accessing a macOS function to do the rename. I suspect that you could go into Terminal and use the mv command and get the same results.

I know that in general, if there's a file extension and you have an app that is associated with that extension, then that's the default application. HOWEVER, you can change the file in Finder so that it's associated with a different application.

AND, it's possible to set the "Hide File Extension" flag (or whatever it's called) so that technically it still has the file extension, you just don't see it in Finder. I don't know how that affects KM actions.

Regarding using a regex to not change the extension, KM's Filter action lets you do all sorts of things to a file path, including removing the extension, retrieving just the file name, etc. Is it easier than just using a regex? Depends on how comfortable you are with regex. And even then, I prefer to use the action just because it's clear(er) what I'm trying to do.

I can conceive of how to use the basepath if the command was to replace just the basepath, not the other way around. What I need is a way to tell KM to take the content of my variable and only replace the basepath of a file stored in another variable. I thought that was what I was doing with the rename command since "rename" should not include the extension since the extension is not really part of the name. If you are willing to write a short macro as an example where the content of one variable replaces just the basepath of a file, Maybe I would understand it better. Seems like the filter is about getting data, not pushing new data to a portion of a files naming structure. I am probably just not understanding it.

You understand correctly. The Filter action lets you get parts of a file path, then you can piece them back together again using the standard Set Variable action, along with whatever parts you want to replace.

Like I said, it's not easier than regex, and now that I look at some code, it's not even necessarily more clear than regex, if you understand regex of course.

Uh, no. No, no, no. :wink: Extensions really are part of file's name.

There are three parts to any filename (and have been for a very long time). They are 1) the path, 2) the base name and 3) the extension. Ignore any one of them at your peril.

The Split Path action lays this our nicely for you, assigning the various parts of a file's name to variables:

ss-657

3 Likes

Got it. I will research and work this in to my macro. Seems like just what I have been looking for: a way to distinguish only that part of the complete name :slight_smile: that I am interested in changing. Assigning the contents of my variable FileName just to the Base name variable should protect the file from being altered and allow me to leave the .pdf out of the basename. Should work better than that I would think since it is specifically leaving the extension alone.

So I made a copy of my macro and inserted the split path and created a variable for the Base name. I then used move or rename to change the base name variable contents to the contents of the variable I had set for the new file name. It does nothing. My question now is: When you use the split path, Do you need to set a variable for all four options and then after changing the contents of the base name, enlist some other action that merges the pieces back together? As it sits now, it appears to ignore the move or rename action. Scenodarily, is there a limit on what this forum can accept as to length of macro? Last time I added my macro image, it only added half of it. Can you select a portion of the macro to share versus the whole thing?

Thanks

Nobody replied to your question about whether the image you posted was complete or just half. So I’ll respond now: I can see the complete macro in your image (beyond the teal-coloured notes to the end).

If you want to post an image of just part of a macro, select those actions that you want to post by clicking on them (they’ll then be highlighted by a blue “perimeter”) and then Edit > Copy as image. I’m not at my Mac now but I’m pretty sure that’s how you do it.

Somehow I managed to miss the Split Path action, even though I've used KM for years. Thanks for pointing that one out!

New in Version 8, I believe -- which seems like only yesterday!

1 Like

One other item to consider. The MacOS maintains something called the LaunchService database that links file types to preferred applications to open that filetype. Both file extensions and file URLs identifiers help the OS determine which apps to use to link a document to an app. If you do a Get Info on a document in the Finder, you can choose to assign an app to a given file or to assign that app to all similar files. LaunchServices database manages this. That way you can change the default app to open PDFs from Preview to another app (e.g., PDFExpert or PDFPen). Sometimes this database gets corrupted and need to be recreated. Sometimes the user assigned a particular type to open in an app but then forgets that assignment and wonders why a particular document is opening in the "wrong" app. Here's an article about LaunchServices that may be helpful. There is also an article linked toward the bottom about fixing LaunchService problems. https://eclecticlight.co/2017/08/10/recent-items-launch-services-and-sharedfilelists/

1 Like

Thank You