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

Use Case

  • Easily replace all spaces with dashes in File or Folder NAME in Finder, Path Finder (PF), and ForkLift
    • You Can ADD other Apps if you like
  • Provides option to work with any app

Example Use in Finder


Example Use in Other App (BBEdit)

Note: The example uses a Trigger by Name, but you can of course use any trigger you like.

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

~~~ VER: 2.0    2019-03-02 ~~~


Replace Spaces with Dashes in File Name in @Finder and Other Apps [Example].kmmacros (14 KB)
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.

Revised to Accommodate Needs in this Topic:

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




  • Replace All Spaces in File/Folder NAME with Dashes
    • Designed to work with Finder, Path Finder (PF), and ForkLift
    • But Provides option for other apps


  1. KM 8.2+
  2. macOS 10.11.6 (El Capitan)

How To Use

  1. Select a File or Folder in Finder, Path Finder, or ForkLift
    • OR, select text of File/Folder NAME in any other App
  2. Trigger this macro.
    • It will then test for supported app, and makes the changes
    • IF Other App, then an Alert will be shown allowing user to select the Text to be changed.


  • Carefully review the Release Notes and the Macro Actions
    • Make sure you understand what the Macro will do.
    • You are responsible for running the Macro, not me. ??
  1. Assign a Trigger to this maro..
  2. Move this macro to a Macro Group that is only Active when you need this Macro.
    • Most likely this will be a MG for Finder, Path Finder, and/or ForkLift
    • If you want it to work with any app, then put in a Global MG
  3. ENABLE this Macro.
    (all shown in the magenta color)
    • SWITCH: Based on FrontMost App NAME
      • ADD new Cases for other Apps you want to use

TAGS: @Finder @PathFinder @ForkLift @Files @Folders @Rename


  • Any Action in magenta color is designed to be changed by end-user


  • To facilitate the reading, customizing, and maintenance of this macro,
    key Actions are colored as follows:
  • GREEN -- Key Comments designed to highlight main sections of macro
  • MAGENTA -- Actions designed to be customized by user
  • YELLOW -- Primary Actions (usually the main purpose of the macro)
  • ORANGE -- Actions that permanently destroy Variables or Clipboards,
    OR IF/THEN and PAUSE Actions


  • While I have given this limited testing, and to the best of my knowledge will do no harm, I cannot guarantee it.
  • If you have any doubts or questions:
    • Ask first
    • Turn on the KM Debugger from the KM Status Menu, and step through the macro, making sure you understand what it is doing with each Action.

1 Like

Great GUI Scripting macro!

Fantastic macro - very useful!

I tested it and it works in Finder, ForkLift AND in any text document such as TextEdit, Pages, TextSoap8 or on this forum… where the user needs to set dashes between words - list of links or list of image names, for example:

this is my beautiful nature image.jpg

will become:


(Doesn't matter if the extension is selected or not.)
(Once I understood the matter, I disabled the alert.)


Thanks @JMichaelTX for sharing the macro. It can often be so easy to improve your workflow.

I have integrated the use of Dashes into my PDF Print macro and it works great.
So I can write the filename fluently and everything else is done by KM now. :+1:


I'm glad you found it easy to use/modify my macro for your workflow.