Search code examples
batch-filexcopy

Batch XCOPY with variables invalid path


Okay, so this is my current code:

set path=%~dp0
set path1=%path:~0,-1%
for %%f in (%path1%) do set outPutFolder=%%~nxf
set outputPath=C:\Users\Steven\Google Drive\Backups\%outputFolder%\
C:\Windows\System32\xcopy "%path%" "%outputPath%" /E /D /W /F /Y

XCopy returns invalid path. The paths appear to be correct. Thanks in advance.


Solution

  • You don't say precisely what this code is intended to do, but try, in your xcopy "%path%*" in place of "%path%" which should copy all files to the destination

    It's not a good idea to change path since path is established by Windows as a semicolon-separated list of directories that is searched for an executable if the executable does not exist in the current directory.