Create folder by file name - insert file

I have a ton of PDF's that have been scanned and named via OCR, the PDF's are all the old parcel maps and documents that will be hyperlinked to the ArcReader map I am creating.

Trying to create a command line code (or a .bat) that will create a folder and give it the same name as the file, then move the file into the folder. So far I have code that will create the folder but fails at moving the file.

for /f "delims=|" %f in ('dir *.pdf /b') do md %~nf & move %f .%~nf *.pdf

The "delims=|" is wrong, trying to create the folder name and include the spaces, (ie. S04-25 Bain School Road Property)but it is creating a new folder for each word in the PDF file name.

Keith, GIS Planning, Mint Hill


  • If the following is in a batch file, replace "%f" with "%%f":

    [code]for %f in (*.pdf) do md "%~nf" & move "%f" "%~nf"[/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion