Renaming Files in Folder by Removing Everything but the Name

Hello!

I am not posting an example because I don't know where to begin.

Files names in my Finder folder look like this:

  • John Smith- jxebj8hn837.xlsx

  • Suzy Chan- p890j9jijj.xlsx

Etc...

My goal is to rename all of the files to just the name (and file type). So everything before the "-"

Any ideas?

https://forum.keyboardmaestro.com/search?q=rename%20finder%20files%20order%3Alatest

Hey Mike,

Please be more specific...

  • All files in a folder?
  • Only selected files in a folder.
  • Files should remain in place?
  • Etcetera.

-Chris

Here something simple to start with:


Rename Files [1].kmmacros (6.0 KB)

Untitled-pty-fs8


  1. Set a trigger in the macro header (e.g. a hotkey).
  2. In the first (green) action, set the folder path where your files are located. (You can drag the folder from the Finder into the text field of the action.)

If all file names are structured like your two examples, then this should work.

If there are files with identical names before the hyphen, then the first one is renamed and the other ones are left untouched. The notification tells you about any duplicates.

Unless you have thousands of files, this should be reasonably fast.

As always with potentially destructive actions (Move/Rename), first try the macro on a test folder, and make sure the folder path is correct!

– Tom

2 Likes

Hi Chris!

All files in a folder, files should remain in place.

I had to download about 300 files. I moved the downloaded files to a new folder. I need the files in that folder renamed to remove everything after the "-" and left in the folder.

1 Like

Thank you Tom! I will be giving this a try here shortly.

@Tom It worked flawlessly, thank you.

2 Likes