Copy a pdf filename & rename several videos with that filename that reside in the same folder

Just wondering if anybody could help with a file renaming situation I'm trying to work out. I've found bits and pieces of what I'm trying to do in different forum posts but I can't seem tie it all together. I'm a bit shaky on KM techniques above the novice level so any advice would be much appreciated.

I made a 30sec screencast showing the manual process if it helps:
:movie_camera:VIDEO EXAMPLE (30sec):
https://vimeo.com/374951606
PASSWORD for the video: keyboardM

HERE'S MY SITUATION:

  • On my Mac desktop I have a folder called 'INPUT'.

  • At random times of the day a batch of four .MOV files and one .PDF file will land in this 'INPUT' folder, usually within a few minutes of each other. NOTE: Sometimes the .MOV files show up first, sometimes the PDF shows up first, it's unpredictable - but it is always 5 files in a batch.

  • The PDF will always arrive with a filename that has a repeating pattern, specifically the letter 'A' followed by 7 digits. Example: A1234567

  • When a batch of 4 video files and 1 pdf are detetected in the 'INPUT' folder I'd like to copy the filename of the PDF and rename each of the .MOV files with that filename followed by a number (it doesn't matter which number is connected to each video).

FOR EXAMPLE:
A1234567.pdf
A1234567-1.mov
A1234567-2.mov
A1234567-3.mov
A1234567-4.mov

  • When those are renamed then I'd want to MOVE the 5 files to another folder on my desktop called 'OUTPUT'. BTW: This last step was kindly answered a long while back for me at this link:

https://forum.keyboardmaestro.com/t/wait-for-2-files-w-same-name-different-extensions-to-land-in-a-folder-then-move-both/11253

If any idea's come to mind I'd be very appreciative.

This works for me:

Move and Rename Files with PDF File Name.kmmacros (6.4 KB)

There's a small bug with this method in that it might display a "File action failed because destination already exists" notification when adding all four MOV files at once, but if you can overlook that, it seems like it should do what you want:

Thank you so much for putting this together. I really appreciate it! What's weird is when I drop the files into the 'INPUT' folder on my mac on the desktop it only sends the pdf file to the OUTPUT folder on the desktop without renaming the .mov files. In case it helps here's a new 35 second screencast of what happens when I try your 'Move and Rename Files with PDF File Name' macro with different variations on how the files might show up in the 'INPUT' folder. I don't quite grasp what might be going wrong, do you see anything by chance?
Thanks again!

Here's how it plays out on my mac with KM 9.0.3:
https://vimeo.com/375063829
PASSWORD for the video: keyboardM

No problem. Unfortunately, I can't see what might be going wrong for you because the password on that video seems to be incorrect. In the meantime, I think I figured out how to get rid of the notification I mentioned before (the macro just needed a semaphore lock at the beginning) and it's possible it might help with your issue too:

Move and Rename Files with PDF File Name 1.0.1.kmmacros (6.7 KB)

One thing to keep in mind is that the macro expects the FileCounter variable to be 0 before any files are added to the INPUT folder. It should reset it to 0 automatically once the four MOV files and the PDF file have been added, but if it hasn't been working for you right in testing, you may want to reset it to 0 manually when adding new files to an empty INPUT folder.

1 Like

Bingo! Setting the counter to 0 like you suggested seems to have worked!!! Thanks a million for your help. This is really going to come in handy in a big way and I learned a lot by going through each of your steps and trying to figure out what each step does.

1 Like