Move files to diff folders based on filename

August 22, 2009 at 17:01:47
Specs: Windows XP
I have a folder with a few hundred PDF files and would like to sort them to various other folders according to selected words in each PDF title.

The unsorted PDF folder is

C:\PDF

The destination folders are (for example):

D:\PDF\MATH
D:\PDF\ENGLISH
D:\PDF\GEOGRAPHY
D:\PDF\BIOLOGY
D:\PDF\CHEMISTRY

The words used for searching every PDF title (filename) would obviously be: math, english, geography, etc. If there's more than one way of doing this, I'd be interested to know.

thanks


See More: Move files to diff folders based on filename

Report •


#1
August 22, 2009 at 18:06:25
There are multiple ways to do this, here is probably the easiest(in my opinion):

pushd c:\pdf
for %%a in (MATH ENGLISH GEOGRAPHY BIOLOGY CHEMISTRY) do (
    move "*%%a*.PDF" "%%a"
)
popd


Report •

#2
August 23, 2009 at 05:04:12
@ Judago

Wow, thanks it works great, it took just a couple of minutes to sort through 1,200 Pdfs. I had to create the destination folders first in C:\PDF

I'd been trying to find a solution from XP's command prompt but not having much success.

thanks again

EDIT

I afterwards came across the util (copyright 2000, cooltools), xmove.exe, which uses the syntax

XMOVE source_dir file_pattern destination_dir [modifiers]

by using the wildcard * before a word, after a word and either side of the word, all files whose filename contains that word can be moved to another folder:

xmove C:\PDF math* C:\MATH
xmove C:\PDF *math C:\MATH
xmove C:\PDF *math* C:\MATH

Whether copy, move, xcopy, xxcopy, robocopy have a similar ability to deal with wildcards, I'm not sure.


Report •

Related Solutions


Ask Question