Page 1 of 1

Passing Directory Name with spaces in it

Posted: 25 Feb 2011 19:52
by parodytx
Newbie problem perhaps but I cannot find a solution even after searching the board.

An unpacker program created a directory that was supposed to be a bunch of individual files. Instead it created a couple of thousand directories names similar to the file names with spaces and sometimes dashes in them. Each directory contains a single file similar to the the directory name:

Toplevel
Name of first directory
\Name of first directory file.pdf
Name - of second directory
\Name - of second directory file.pdf
...
etc.

I would like to create a batch file to recursively send the directory name to a second batch file that moves the file to Toplevel, then deletes the directory names.

Any assistance would be greatly appreciated.

Re: Passing Directory Name with spaces in it

Posted: 26 Feb 2011 04:46
by !k

Code: Select all

@echo off &setlocal enableextensions
for /d /r %%d in (*) do call :up "%%d"
goto :eof

:up
move "%~1\*" "%~dp1" &&rd /q %1 2>nul
goto :eof

place in Toplevel & run