Rename the One File in a Folder the Name of Which Contains X

Hi!

This is probably quite simple to do, but my knowledge in these things is very patchy...

I have a folder with files that all have names of the structure "UID Title", UID is a 12-digit ID that is different/unique for each file in the folder. I need a macro that as one of its steps changes the "Title" part of the file with a certain UID in its name to a string it gets from previous steps. Is it possible to use the "Move or Rename a File" action to do this without knowing the complete name of the file that is supposed to be renamed – only the UID? Or do I have to use the "For Each Path in Folder" action to change "all" the paths that contain the UID – although I already know that it's just one?

Yes.

But there are several ways to implement this.
We need to start with a clear example from you:

  1. Source File Name
  2. UID of the file you want to change
  3. New Title you want
  4. Example of renamed file

Questions:

  1. How do you want to identify the folder/file?
    • Select the folder (or files) in the Finder, then trigger the macro
    • Set a specific folder to always use in the Macr
    • Prompt for the folder or file to change
  2. What is the source for the replacement Title?
    • Enter for each file
    • UID Title list in Macro
    • UID Title List in file

If you already have a macro that partially works, then please upload your macro .

Please read:
Tip: How Do I Get The Best Answer in the Shortest Time?

Hi Michael!

Sorry, I thought my info was clear enough and an example wasn't necessary – but given the few reactions you seem to be right :wink:

Below is a minimal example. The UID is copied from the selection when the macro is triggered (e.g. by a hot key trigger) – assume that the variable %newName% is taken care of elsewhere. I want to know whether there is a way to fill the first field in the "Move or Rename File" action without knowing the second part of the file name. I tried just putting the * character behind the UID to signal that (because I vaguely remembered that I had seen something similar to that work in other apps/contexts), but that didn't work.

Oh, sorry. An example for a file name would be "202009031114 [DEF] Organic Farming.md". All the file names in the folder are similar, some also have a component like "#SmithA" behind the UID.
Is that enough for you to work with?