Renaming Files in Directory B from Files in Directory A

You're using the KM version?

The AppleScript version correctly handles case-change-only renaming.

A pure shell script mv also correctly handles case-change-only renaming.

It would appear that the native move-action in the KM version does not see a case-change as a legitimate change...

@peternlewis? (See post #20)

The problem is easy enough to work around, but perhaps it's something Peter can fix.

Yes, that is correct: I’m using the KM version.

Thanks for looking at it and explaining that.

Tom

1 Like

Okay, this one is on me! I think I see what the problem is: The destination files are on a thumb drive formatted as Microsoft NTFS. I just noticed that even if I change the case in the file name manually, it reverts back to the original case. For instance, changing the word “Of” to “of” reverts back to “Of” after committing the change by hitting enter. It will stick if I change it a couple of times, but the first time (as a paste would be) changes right back to whatever the case was originally. Odd…

Tom

The problem occurs with two folders on my internal APFS drive, so your issue with the NTFS and the thumb drive is not the only one.

Okay, thanks for that. Fun troubleshooting when it isn’t “mission critical.”

Correct. Keyboard Maestro will not let you move/rename a file on to an existing file, including if the existing file is the same as the original file with different case.

1 Like

Thanks for confirming, Peter.

I suppose one way to work around this would be to test for an "identical" name that also has case differences. If "true" paste the name from the source file with an added character appended to "force" the case change, then erase that added character after the paste. Or simply go with the AppleScript solution, using KM to trigger the script.

Tom

The AppleScript is the simplest way (provided that you know AppleScript).

Another alternative is to use the shell and an Execute a Shell Script action.

We're not pasting when using the KM move/rename action, we're essentially moving the file to a new name.

But you're correct in principle. When detecting a string that is equal except for case differences we write to a temp file with a different name and then rewrite to the desired name.

Here's a case-comparison example:


Download: String Case Comparison v1.00.kmmacros (9.9 KB)

Macro-Image

Keyboard Maestro Export

Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.

System Information
  • macOS 10.14.6
  • Keyboard Maestro v10.2

You can move it to a unique name, and then move it to the destination name.

That will result in the failure having it renamed to a unique name though.

So you could do

  • Move to unique name
  • Move unique name to new name
  • Move unique name to old name

The latter configured not to report or abort on error. That way if the second move fails, then the third move will revert the original change.

Hello Peter and Chris,

I approached it a little bit differently for now. Since the source file names have single digits for tracks 1-9 and the destination has a leading zero for tracks 01-09, the case of those names are handled exactly as they are in the source names, as the source names actually have different characters (no leading zeroes).

For all other tracks from Track 10 on, I have a KM macro that appends the letter "z" to the end of the destination file names, just before the "." for the extension. So, for instance, the destination file name of

10 All Quiet On The Western Front.wav would become
10 All Quiet On The Western Frontz.wav

Now, the name of the source cue is

10 All Quiet on the Western Front.wav

and that name with the proper case becomes the exact same name of the destination file, since the destination has a different character (z) than the source cue.

It’s a very quick process and handles the issue correctly, so I think that is the way I’ll go for now.

Tom

1 Like