Reputation: 15
I want to put some files into some particular folders that shares same identification (numbering).
File Pile_XX.jnl.txt to a folder XX_(FolderName), XX is the identification number.
This is what I did, but it does not work
for %%i in ( 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32) do (
echo copying Pile_%%i.jnl.txt
copy Pile_%%i.jnl.txt %%i*/Comp/mdl/pile.jnl
echo.
)
it says wrong syntax
thanks!
Upvotes: 1
Views: 63
Reputation: 56155
use another for
to get the subdirectories and copy to them one after the other:
echo off
for /l %%i in (3,1,32) do (
echo --- %%i ---
for /d %%d in (%%i_*) do (
echo copy "Pile_%%i.jnl.txt" "%%d\comp\mdl\pile.jnl"
)
)
Remove the ECHO
if the output satisfies you.
(I changed your %%i
loop to a for /L
because it's shorter, but on the other hand, it works only for consecutive numbers)
Upvotes: 1