windows - looping through a directory in bat, going up a directory using bat file -


i have bat file part of looks like:

set test=test /d %%x in (..\*.%test%) xcopy "%%x" c:\path\%test%\%%x\ /s /e /f xcopy ..\dir c:\path\%test%\dir\ /s /e /f 

the loop not work, xcopy does. if move contents of directory above current directory , change code remove "..\":

for /d %%x in (*.%test%) xcopy "%%x" c:\path\%test%\%%x\ /s /e /f 

it works. can please tell me why bat script in loop cannot directory? approaching wrong?

edit: have changed command after seeing ths answer still not work:

for /d %%~nxx in (..\*.%mui%) xcopy "%%~nxx" c:\temp\%test%\%%~nxx\ /s /e /f 

i receive error:

%~nxx unexpected @ time 

edit #2: still cannot work, commands have looked like

for /d %%x in (..\*.%test%) xcopy "%%~nxx" c:\temp\%test%\%%~nxx\ /s /e /f  /d %%x in (..\*.%test%) xcopy "%%x" c:\temp\%test%\%%~nxx\ /s /e /f 

it can. %%x contain ..\xyz.test, not xyz.test, not want in xcopy target.

replace %%~nxx (for "name , extension of x") chop of path.

for /d %%x in (..\*.%test%) xcopy "%%x" c:\path\%test%\%%~nxx\ /s /e /f


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -