I hardly work with batch files and I need a batchfile which moves PDF files to a new subdirectory "PDF" in the current context path.
For example my directory tree looks like this:
A/a.xml
A/b.xml
A/x.pdf
A/AA/a.xml
A/AA/y.pdf
B/z.pdf
Desired tree after batch processing:
A/a.xml
A/b.xml
A/PDF/x.pdf
A/AA/a.xml
A/AA/PDF/y.pdf
B/PDF/z.pdf
My first try looks like this:
@ECHO OFF
FOR /r %%a IN (*.pdf) DO (
MKDIR "%%~pa"/pdf
MOVE %%a "%%~pa"/pdf
)
But this creates a loop because the batch file also process all moved PDF files. Any help appreciated. Thank you!