Batch Rename Files Removing a Text String

Hello, I apologize for my bad English.
I would like to use Keyboard Maestro to speed up my work, but I'm not very good at coding.

I make thumbnails with VLC of some of my movies. The result I get are files with these names:

tn_myvideoclip_01.mov-00001.jpg
tn_myvideoclip_02.mov-00002.jpg
tn_myvideoclip_03.mov-00003.jpg

Is there a way with Keyboard Maestro to erase this ".mov-00001" part and then get

tn_myvideoclip_01.jpg
tn_myvideoclip_02.jpg
tn_myvideoclip_03.jpg

My problem is that the string is not always the same (the numbers change, 00001, 00002 ...) and therefore I don't know how to get this result.

It's something I can do?

Thanks in advance and sorry again if my English is not clear.

Here what I have done for you.

You need to set Local_dir to your video dir.
and it will use regex to extract and rename the files.
Have tested it and it work.

You can import the macro.

[EXP] Rename MOV file.kmmacros (4.3 KB)

1 Like

Hello, I really thank you for this work!
I used %FinderInsertionLocation% in Set Variable dir to. (I see this in the forum)

Schermata 2021-03-14 alle 18.38.01

If I go in the dir where files are when I select the macro from the menu nothing happens. Do I have to change other things in the macro?

Thanks in advance for your time.

From my side when I use FinderInsertionLocation, it did work. Nothing need to be changed. Just trigger it from status menu , and it will work

What version of KM and MacOS you are using ?

1 Like

I use 9.0.4 on El Capitan (10.11.6)

Hey @stirner,

You may want to look at this macro by @peternlewis.

-Chris

I think you'll find what you need here: Rename Files Mystery. There's a Perl version (which I recommend) and a JavaScript version.

2 Likes