I have a series of files I need to copy into folders.
The file names will always start with a number (i.e. 2015_071, 2015_072).
The files will always be consistently named at their start in this way.
The folders were I am copying to will also start with the same number but have a ‘second’ part which is different (i.e. ‘2015_071 (Adam)’, ‘2015_072 (Brown)’).
Is it possible to copy files to a folder where you only ‘know’ part of the name of a folder? That is what functions/actions I need to use and how to modify them. Rather than detailed code I would like to know whether it is possible so I can investigate myself.
Assuming there is only one match, you’ll get only one line back in response, and that will be your path which you can use in the Move or Rename File action.
Alternatively, you can actually do the move in the shell like this:
And finally, if you prefer to stay away from the shell expansion, you can do something like this in Keyboard Maestro actions:
For Each file Path in Folder Contents "/path/to/directory"
if variable Path contains "/2015_071"
Exit from Loop
Then, assuming the Path matches exactly once, you’ll finish with Path being the path to the folder.
In both cases, if the path matches more than once, or does not match, you’re going to be in trouble, so you may want to check for that and report the problem if that is the case.