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

Title says it all. A simple four step macro and a more complex one both convert pdf files to TextEdit when you are using the action to change the name via a variable. There is nowhere in the macro where it is being told to alter the file type. Unfortunately, the file cannot be accepted as a TextEdit and must be converted back. I don't want to upload the macro because it is folder specific etc. the whole macro to see the effect is:

1.Prompt for File, set variable: File
2.Open %Variable%File%, with default application (which is Preview)
3.Prompt for user input, Title: Name, Prompt: What customers name do you want to fill the variable FileName?, Variables and Default Values: FileName
4.Move or Rename File %Variable%File%, to %Variable%FileName%

If you recreate this, the pdf you start with will end up a TextEdit file. No good. Thanks for any help.

Stefan

I'm guessing the extension is either getting removed, or changed.

If you are saying that it is a pdf marked as a TextEdit, that is not the case. The file cannot be opened with dedicated pdf software, neither can it be shared with systems that do not accept the TextEdit format.

For step #3, enter something like "test.pdf" (notice the .pdf extension), and try it.

Dan

Since it is most likely an error in your macro that is causing this unwanted behavior, you will need to upload your macro for us to provide useful help. If you don't want to upload your actual macro, then you can create a test macro that contains just the actions that are at issue, and upload that macro. Creating a test macro is also a good debugging technique.

I have run it on actual pdfs and they always become TextEdit files. This is not a theory, it is a fact that it is occurring.

rename w/o screen capture Macro (v9.0.4)

rename w-o screen capture.kmmacros (4.3 KB)

Thanks for posting your macro.
It runs fine for me, as expected, running Keyboard Maestro 9.0.6 on macOS 10.14.6 (Mojave).

Runs fine for me too. And even if I don't specify a .pdf extension, I still end up with a pdf file.

Thanks for the quick feedback. I am on Cataline 10.15.6 and it converts to TextEdit every time. I made a screencast video on my screencast account because I couldn't figure out how you embedded the video. It rejected my.mp4 file format. Hope you will view it and we can get to the bottom of this.

Thanks again

Looks like it embedded. Didn't know it would do that.

And what happens if you include the .pdf extension in the file name?

That did it. In all these years of working on computers, I never knew that a rename without specifying the existing file type in the new name could cause it to default to a different format. Thanks. Now I need to go back into the main macro and delete all the export to pdf stuff and fix the regex that deletes the file type. Should work as expected. I will give a final update on the status of that macro to make this thread complete. Thanks again.

Unfortunately whereas that worked in the simple macro above, it failed to solve the problem in my main macro. I tried .pdf and .PDF . Both were converted to text edit. The macro is big, complex, moves the viewport in preview all over the place to zoom and center the viewport on the name and address of the customer, depends on folder names, etc. I am going to upload the image of the macro to see if anyone can suggest better regex in case that is confusing the system. That seems to be where stuff goes wrong for sure.

Tell me if you are seeing beyond the teal macro notes box. Looks like my macro is too long to post the image perhaps. I am only seeing the first half of it.

It appears I have it fixed, at least for now. I think I have thought this at least three times through this process. I have two manipulations of the variable holding the OCR screenshot which is the content destined to become the file name. The way I had it, the first search and replace variable with regex took zeros off the end of the name that represent where a zip code would go if the person typing in the address would do their job. It replaced those zeros with one blank space. The second looked for line breaks and replaced them with spaces. The end result was the textEdit file conversion. I reversed the order of the two search and replace actions and the file got converted to a "document". Interesting. I then changed the end of the file name itself to go from MD to MD.pdf . I had tried the .pdf thing already which worked on a one word filename but not on these longer names. It looks like I have the correct combination and order of steps to get a respectable detailed filename without any conversion of the file to another format. At least it worked once so far. It may be that my goal was too lofty as a response from KM support showed no recognition that their renaming action could ever change the format of a file, yet it can. I did some research this morning into naming conventions for pdf files and didn't find any specifics but some general comments on "things going wrong" if names are too long, have two spaces side by side, etc. I suppose things going wrong might include file conversion as it turns out.

I am marking this as a solution because it did turn out to be part of the problem, but not the whole problem. Adding .pdf to the end of the new name was required for me to get it working. Thanks for the insight.

Here's what I think is happening regarding the .pdf extension:

  • On your system, if a file doesn't have an extension, and isn't otherwise associated with an application, Catalina defaults to having TextEdit be the default application.

  • There's no way that KM's Move/Rename a File action actually changes the contents of the file. Trust me on this. There's three ways you can verify this:

    1. The file size doesn't change. If the contents were being converted, the file size would almost certainly be different.

    2. Use Finder to rename the file and add the .pdf extension, and it should now open in Preview. It is remotely possible that it won't default to Preview, athough I think that's unlikely, but if it happens, launch Preview by itself and use File>Open to open the file.

    3. You could use diff in Terminal to compare a copy of the original file to the renamed file. This works best with text files when something has actually changed, but in this case, it should say that the files are the same.

Regarding the rest of your issues, I didn't completely understand your explanation, but I suspect something funky is happening to the file name. Your best chances of finding the problem are to focus on odd characters in the file name.

1 Like

I've just done a little experiment on my Mac which shows odd results that may explain why @StefanMach isn't going insane...

I selected a pdf file in Finder and then clicked again to rename it. I just deleted the extension ".pdf" and the file automagically appeared as a "TextEdit.app Document" in Finder.

Opening the file in TextEdit produces gibberish, while the file opens fine in PDF Expert so no actual format conversion has taken place.

Here are the before and after screen grabs:

The moral of this story, which @DanThomas has already stated is add the .pdf extension to the filename.

BTW - I'm on Mohave.

2 Likes