You are using the Universal Naming Convention (UNC) for both the source and dest variables. Not a problem but they are different than local folder paths. The
\\network_path in both variables is not a folder name but the machine name of the network device.
test and
test2 in each of the variables is also not a folder name but the sharename used to access the device or when mapping the remote drive to a local drive letter. If you want everything to be copied to the
test2 folder, you will have to create it yourself.
XCOPY will do this for you if you add
test2 to the
dest variable on the xcopy instruction.
@echo off
setlocal enabledelayedexpansion
set source=\\network_path\test
set dest=\\network_path\test2
pushd "%source%"
for /f "tokens=*" %%G in ('dir *.* /b /ad /od') do SET newest=%%G
xcopy /s /e /i "!newest!" "%dest%\Test2\!newest!"
popd
cmd /k
You may have to tweak the
xcopy parameters, but this should work if my interpretation of your request is correct.