Help with 'If name starts with…

I want to create a macro that checks the filenames of the selected Finder items/files.

If the the filenames start with z_ (e.g. z_test_01.png, z_test_02.png etc.) then remove the ‘z_’ prefix from the files, then perform ‘some other actions’.

If the filenames don’t have the ‘z_’ prefix then skip the renaming part and just run ‘some other actions’.

So it would be something like this:

If

Selected Finder items’ filenames start with z_

Then
Rename the files to replace “z_” with “”

'Run some other actions’


Else

‘Run some other actions’
(skip the file renaming part)

Is something like this possible?

Certainly:

Process Files.kmmacros (4.5 KB)
25 PM

The If Then Else action highlighted in yellow only runs if the selected file name starts with "z_", while the actions used in place of the green placeholder will always run no matter what. Feel free to ask further questions if anything about how this works is unclear.

2 Likes

Thanks a lot, that works great!

1 Like