Unknown macro - dashes-for-spaces in filenames -?

Hi JMichaelTX,

Thank you for the input.

  • The 'lost macro' was not part of my KM macros, it still exists on the external disk (SuperDuper- Clone). I got it from (?) years ago, don't remember how it was set on my machine - mysterious.

  • Great that you came up with this KM macro above ” Replace Spaces with Dashes…” however when selecting a (read & write) file and triggering the macro -> error: Not permitted, Library to Library??

See here:

image

… ?!

/

with best regards,
Omar KN
Stockholm, Sweden

Hey Omar,

Boot from your SuperDuper Clone drive.

Open the Keyboard Maestro Editor.

Select the “All Macros” group.

Select Menu Item: View > Sort Macros By > Date Used

Run your macro.

Switch back to the Keyboard Maestro Editor with the SYSTEM app-switcher or the Dock.

Your just run macro should be at the top of the list in the Keyboard Maestro Editor.

-Chris

Thank you Chris, I did exactly that but nothing there!

Now I could just wait for JMichaelTX's macro to work (above 4/5), a macro which probably is even better than my old one…

…but I cannot wrap my head around the fact that on the SuperDuper Clone drive there is a working macro (not in KM list) which is working there for ≈ 4 or 5 years 'incognito'!

It has to be somewhere and what is special is that 3 keys are pressed down, and then the 4th key (the dash) is also pressed (video above). This is bugging me.

There should be other people / web designers etc. who use it.

/

with best regards,
Omar KN
Stockholm, Sweden

I don't think you triggered my macro. It does NOT use the "mv: rename" command shown in your Notification:

image

Also, I just tested my macro using a folder inside of the /Library folder, and it worked fine, even though I had to enter my Mac password.

Here is the KM Engine log from my test:

Execute macro “Replace Spaces with Dashes in File Name in @Finder @PF” from trigger Duplicate Macro Palette

Are you running Mojave by chance? That could cause problems between KM and the Finder with permissions.

Hi JMichaelTX ,

Your macro (above #3) does function alright, thank you!


Another script (shell~), to apparently do the same is what I found on the web:

Replace spaces with hyphens in Mac file names:
(https://snipplr.com/view/75070/replace-spaces-with-hyphens-in-mac-file-names/)

for i in *; do mv "$i" "echo $i | sed -e 's, ,-,g'"; done

But how to clad this script into a shell - ?


PS: But your macro is fine, which will do - !

Hey Omar,

You ran the test when booted from the SuperDuper volume?

Hmm...

The only logical conclusion is that either you're missing seeing the macro in the Keyboard Maestro – OR Keyboard Maestro is not the agent running the macro.

Quit the Keyboard Maestro Engine and try again on the SuperDuper volume.

Report back.

-Chris

Started from the clone,

Quit KM engine,

Tried the unknown macro,

it worked => it's not a KM macro.

Also remarkable it's working with 3 keys down + 1 key step bey step: this is not like usual 1 trigger macros. It must be some other script, where could it be stored?

/okn

Hi @JMichaelTX et al.

I wanted to adapt this macro ( Replace Spaces with Dashes in File Name in @Finder @PF) to use it with ForkLift instead of PathFinder:

So the original filename in ForkLift:

heavy wheather crisflo.txt

is changed to:

/Users/okn/Documents/_INPUT-whwebp/heavy-wheather-crisflo.txt.txt

Path (has dashes after running the macro):

/Users/okn/Documents/_INPUT-whwebp/heavy-wheather-crisflo.txt

Why would the macro pick up the path and paste it in front of the filename - with another .txt?

Can you test it please (if you have ForkLift).

/ okn

I don't have ForkLift. Are the manual steps to rename a file in FortLift the same as in Finder? If not, could you make an animated GIF to show you doing the rename manually?

They are almost the same as PF: Commands > Rename

It's as if there's something (the path of this file) in the clipboard?!?

/
okn

@okn thanks for the screenshot, but the reason I asked for:

is so I can see ALL steps you make, including the part where the current name is selected and you type/edit the name.
If you don't know how to make an animated GIF, just do a simple video. You can also search for tools to make it. Here's an example with Finder:

Finder-Demo-Rename-File

I used SnagIT to create the video and convert to GIF.

Alright here is an animated Gif : Renaming+dashes-on-filename-inForkLift.gif

Same after reboot.
Hope you can get an idea what's going on here.

/ okn

Yep, I can. You are NOT triggering my macro, or my modified macro.
Whatever you are doing is getting the file path and pasting that.

Assign my macro a different hotkey, and try again.

... but why then were all spaces replaced with dashes (apart of pasting the path)?

/ okn

Hey @JMichaelTX,

It looks like he is in fact triggering your macro.

The trouble is that copy was being actuated before the rename command finished, so the file was being copied.

When pasted back into a text field it produces a text-path.

Hey @okn,

Try this one.

I've introduced a short pause after the rename command.

Replace Spaces with Dashes in File Name in @Finder @PF @ccstone.kmmacros (8.1 KB)

-Chris

Hey Omar,

Can you zip and post the Automator workflow file for this?

And – do you have a good reason for incrementing the replacement of the next space instead of replacing all spaces at once?

-Chris

=SOLVED_!

The famous, excellent Pause!

A pause of 0.15 seconds made all the difference.

And a reminder that we all do well with some pauses at the right moments! :slight_smile:

/ okn

1 Like

No, the macro provided by @JMichaelTX is clearly better than the original one!

Thank you for the input.

/

2 Likes

This is a very valuable lesson for all to learn in KM. ==Very often the solution to a macro not working correctly is to add or increase the Pause between KM actions== that tell the UI to perform some action for which the KM Action does NOT wait for the app to complete the action.

So when you issue this KM Action:

KM immediately executes the next Action in the Macro, without knowing whether or not ForkLift has completed the "Rename" command.
In this case it had not completed the command, and so the next KM Action, "Copy", copied the file, which translates to the full path of the file.

Placing a short Pause of 0.1 - 0.2 sec allows Forklift to complete the command.

I hope this helps all readers better understand the need for KM Pauses.

@okn, as you learned, that was not a KM Macro, and Chris @ccstone and I have provided you with our macros to provide the same function.

I have just uploaded my Macro revised to work with ForkLift, and any other app the user chooses:

MACRO: Replace Spaces with Dashes in File Name in @Finder and Other Apps [Example]

@okn and @ccstone, if you guys could test this to make sure it works with ForkLift (post results in the Macro topic) I would greatly appreciate it, since I don't have the ForkLift app.

Thanks.

1 Like