I have batch of files named A-01.pdf, A-02.pdf, B-01.pdf, B-02.pdf.... Then I have folder structure 01, 02, 03,.... How can I move all the files with 01 in there name to folder 01, all with 02 to folder 02 and so on?

There are a lot of scripts on the net but none of them seams to fit my case.


Assuming that these files are all in the same folder and the numbered folders are part of that folder as well, open Terminal and run

cd path/to/folder
for i in *.pdf; do
    mv "$i" "${i:2:2}/"

A script like @patrix's is probably the most efficient way, but if you're not comfortable with running shell scripts, you could do it with Automator, with a workflow that looked something like this:

First steps of potential workflow

and so on for -03, -04 etc. (There's probably an even more efficient way to do it with Automator using loops and variables, but I've never tried using those...)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .