Articles

Batch file for copy many files to many folders?

December 7, 2012 at 02:32:16
Specs: Windows 7

hi everyone,

i have many folders like this:
"5002.1 persian"
"6001 russian"
"6014.1 english"
.
.
.
and have files like this:

C:\books\000-C5002-1.pdf
C:\books\001-030-C5002-1.pdf
C:\books\031-067-C5002-1.pdf
C:\books\068-093-C5002-1.pdf
C:\books\094-135-C5002-1.pdf
C:\books\136-167-C5002-1.pdf
C:\books\168-205-C5002-1.pdf
C:\books\206-243-C5002-1.pdf
C:\books\244-283-C5002-1.pdf
C:\books\284-312-C5002-1.pdf

C:\books\000-C6001.pdf
C:\books\001-022-C6001.pdf
C:\books\023-046-C6001.pdf
C:\books\047-081-C6001.pdf
C:\books\082-105-C6001.pdf
C:\books\106-170-C6001.pdf

C:\books\000-6014-1.pdf
C:\books\032-066-6014-1.pdf
C:\books\067-095-6014-1.pdf
C:\books\096-134-6014-1.pdf
C:\books\135-147-6014-1.pdf
C:\books\148-181-6014-1.pdf
C:\books\001-031-6014-1.pdf
.
.
.

I want a bach file for copy files to those folders.

I test this code, but not work:

move *5002-1.pdf 5002.1*
move *6001.pdf 6001*
move *6014-1.pdf 6014.1*

thanks for your help.


See More: Batch file for copy many files to many folders?

Report •


#1
December 7, 2012 at 19:21:12

If the target folders are all rooted off the same directory, this might work:
:: begin batchscript
:: the following is whatever directory these folders are rooted off of
cd \langs
for /f "tokens=1*" %%a in ('dir /b /a:d') do (
pushd "%%a %%b"
echo move \books\*%%~na-1.pdf .
popd
)
:: end batch
not tested, so I used echo in the code. Remove "echo" for live ammunition.

Report •
Related Solutions


Ask Question