I'm currently trying to create a batch file, which actually copy a folder from a server to a clients machine. And I'm playing around with batch file, using xcopy, and it gives me the percentage of completion. I'm not a programmer, i just modified a tiny mount of lines from a code which i got from: https://answers.yahoo.com/question/index?qid=20120229012108AA8EwOA (all credit goes to "Jake").
However, the batch file will actually copied the whole files, including the parent folders, did i miss something here?
Here is the code:
@echo off&color a setlocal enabledelayedexpansion cd / mkdir ZZZDestination set startdir="C:\ZZZSource\Depth1\Depth2\the files" set enddir="C:\ZZZDestination\" echo. echo Please make sure you are connected to Ericsson Network-preferrably via LAN CABLE echo This will copy the files to your machine echo. echo Press any key to continue PAUSE>nul for /f "tokens=1,2,3,4,5" %%a in ('dir /s %startdir%^|findstr bytes') do if /i not "%%e"=="free" set qtyfiles=%%a set filecount=0 for /f "tokens=*" %%a in ('dir /a-d-h-s /s /b %startdir%') do ( xcopy /z /q /s /e /y "%%a" "%enddir%\%%~pa\*.*" >nul set /a filecount=!filecount!+1 set /a percentage=!filecount!*100 / !qtyfiles! cls echo. echo Copying files, PLEASE DO NOT CLOSE THIS WINDOW echo ====================================================== echo Please wait for copying: !percentage!%% Completed echo ====================================================== ) echo. echo DONE, please press any key to exit.. PAUSE>nul
I have tried to modified the xcopy /z /q /s /e /y "%%a" "%enddir%\%%~pa*.*" >nul into xcopy /z /q /s /e /y "%%a" "%enddir%" >nul However, the files inside the subfolder under C:\ZZZSource\Depth1\Depth2\the files will be copied out from the folder. For example, under folder C:\ZZZSource\Depth1\Depth2\the files, there are folder A B C, and inside those, there are each 4-5 files. Those 4-5 files, will all be copied out into "C:\ZZZDestination\".
Anyone have any idea?
Thank you in advance.