Rename string

Hi Everyone!

I have a folder that has files in and I need to change the names of the files as follows:

Original Name: Sales_Invoice_SI-123_Canon Camera
Change to: 123 xxxxx

So I want to delete the part that says Sales_Invoice_SI- and change the part that says _Canon Camera to xxxxx (so the file when renamed will be 123 xxxxx)

There are always going to be a different amount of files in the folder. I have tried all over the place to fix this but cannot find a solution anywhere and am not great with KM!

Thank you in advance for any help :slightly_smiling_face:

Margate

You can't have more than one file in a folder with the same name, so they can't all be named "123 xxxxx" therefore what were you wanting the "xxxxx" to be?

Perhaps if you give an actual example without using a variable like "xxxxx" I might understand.

1 Like

Select the files and right click (or Command-Click if you don't have a right mouse button) to pull up the Finder's contextual menu, select Rename and Bob's your uncle.

If you want to get fancier, there are a number or Rename macros on the site, including one I wrote that handles regular expressions. But I think Finder's built-in Rename function will do exactly what you want.

1 Like

Ah, no good point! I should have mentioned that each file will have a different name such as SI-123, SI-124, SI-125 etc.

Ok, I will look into regular expression. Thank you for your help : )

Regular expressions -- indeed, almost every way of doing what you want -- rely on patterns. So first find the pattern you want to match. That could be as simple "the bit of the Local_theText that starts with SI- and then has numbers, and only numbers, after it":

1 Like

See Rename Files Mystery for some regexp-powered file renaming macros. I use my Perl version here.

1 Like