The purpose of the batch files is to loop through a directory, move all files with a modified date between x and y to a temp directory (located in an archive folder), create a .zip from temp directory, then finally delete the temp directory.
I am calling a batch from a batch. The initial batch uses pushd to retrieve the network path, but then when the next batch is called and the forfiles is used to move files into an archive, the UNC path error is thrown. "ERROR: UNC paths (\machine\share) are not supported."
The two .bat files are in the same directory in the shared network.
I have read the other answer for this similar issue, but none of the answers fix my problem.
First batch file:
@echo off
setlocal EnableExtensions
cls
@pushd %~dp0
:firststep
........
code....
........
echo Calling...
CALL ArchiveTool.bat %MM% %yyyy% \\riskview\EBSArchive
echo Press any key to process next directory...
pause >nul
To here everything works properly.
Failing batch:
@echo off
setlocal EnableExtensions
.......
Code...
.......
md %3\Archive\%1-%2
forfiles /P %3 /D +%1/1/%2 /C "cmd /c if /I @FDATE LSS %mm%/1/%2 move @file
%3\Archive\%1-%2 >NUL & echo|set /p=."
The directory is successfully created, but the forfiles fails.
Best Answer
From my entry at https://en.wikipedia.org/wiki/Batch_file#Setting_a_UNC_working_directory_from_a_shortcut