Computing.Net > Forums > Programming > Move files to diff folders based on filename

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Move files to diff folders based on filename

Reply to Message Icon

Name: ABG
Date: August 22, 2009 at 17:01:47 Pacific
OS: Windows XP
Subcategory: Batch
Tags: batch, search, Filenames, move, Copy
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Judago
Date: August 22, 2009 at 18:06:25 Pacific
Reply:

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


0

Response Number 2
Name: ABG
Date: August 23, 2009 at 05:04:12 Pacific
Reply:

@ 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.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Move files to diff folders based on filename

dos copy files based on filename www.computing.net/answers/programming/dos-copy-files-based-on-filename/17353.html

Moving files from one folder to diffrent www.computing.net/answers/programming/moving-files-from-one-folder-to-diffrent/18858.html

Move a XML file based on content www.computing.net/answers/programming/move-a-xml-file-based-on-content/18945.html