I'm trying to copy files from a network location to my local computer using below script, but it gives me an error message of
unc path not supported
The Script
SET DESTINATION=c:\temp\new
SET DATE_FROM=02/13/2019
SET DATE_TO=02/13/2019
> nul forfiles /P \\sdpw9123app\work\ActiveMQ\logfile /S /D +%DATE_FROM% /C "cmd /C if @isdir==FALSE 2> nul forfiles /M @file /D -%DATE_TO% && > con ( echo @path && copy /V @path %DESTINATION% )"
pause
I also tried using some Robocopy commands but I couldn't get it to work either but ideally I'd like to use the forfiles
command to perform the copy operation.
Best Answer
The issue seems to be with using the
forfiles
command and it not supporting UNC paths. You can usepushd
to map the UNC path for you, then just use the rest of the path after the\\servername\sharename
that maps which contains folders you need to run the commands against. End the script with thepopd
command to disconnect any temporary mapped drives created with thepushd
command.Script
Further Resources
PUSHD
POPD