0

I'm working on part of a backup batch script that moves between two directories on the same drive. I was using Robocopy (with /MOVE switch), but want to speed up the file transfer. As such, I'm trying to implement MOVE. It has worked in one part of my script, but in my C: drive I am getting a weird error.

Here's a sample of a test script in a test folder, that comes up with the same error that I'm getting in the main batch (trying to isolate errors):

set thisdirectory=%cd%
cd ..
MOVE "%thisdirectory%" "C:\Documents\DEL\Stephen Company\"

I have tried that with/without the /Y switch, with all paths hard-coded (no vars), and with "\" added and removed from the end of the source/destination paths.

What happens is that the folder (thisdirectory) does indeed move, but the script won't continue to execute because I get this error:

C:\Documents\Active\Stephen Company>MOVE "C:\Documents\Active\Stephen Company\C123Stephen" "C:\Documents\DEL\Stephen Company\"
        1 dir(s) moved.
The system cannot find the path specified.

I am an "Authenticated User" on this account, but not an Administrator. If I run it in CMD Prompt without a batch script it works:

C:\Documents\Active\Stephen Company>MOVE "C123Stephen" "C:\Documents\Del\Stephen Company"
        1 dir(s) moved.

This also works with full paths (not using the fact I'm 1 dir above to move it):

C:\Documents\Active\Stephen Company>MOVE "C:\Documents\Active\Stephen Company\C123Stephen" "C:\Documents\Del\Stephen Company"
        1 dir(s) moved.

Any ideas how I'm messing this up? Thanks!!

NEW INFO: this may be obvious per the format of the error message I have posted to those (all?) of you with more CMD/Batch experience, but when I send the output of my MOVE command to a text file in the batch code above (> MoveOutput.txt) I only see "1 dir(s) moved". The error that is messing me up (The system cannot find the path specified) directly follows the execution of the MOVE command. NOTE nothing follows the MOVE command in my script that I am getting the error in.

StephenE
  • 1
  • 2
  • 1
    What do you do in your script after MOVE? Because it looks like MOVE is successful but another command after that raises the "_The system cannot find the path specified._" error. – Gino Mempin Jun 14 '18 at 23:59
  • After the MOVE command, put a line of `ECHO got here %ERRORLEVEL%` to see if an error code was returned from MOVE. Be sure to remove or command out any `@ECHO OFF` statements so you can see what is happening. – lit Jun 15 '18 at 00:43
  • @GinoMempin: my script is empty after the MOVE command - could that be a source of error? – StephenE Jun 15 '18 at 14:08
  • @lit: I tried the ECHO %errorlevel% in the script - but the error I am getting in the move command does not allow any subsequent code from executing - so my readout from executing my script is still identical to the Error above. – StephenE Jun 15 '18 at 14:12
  • 1
    Does the batch script resides in the folder your are going to move? If yes then that's the source of error. Because the batch file will be moved along with the folder so when command processor tries to read the batch file to execute the next command it fails to find it. – sst Jun 17 '18 at 09:42
  • Thanks @sst - I found a solution that works for me with that logic - I'm not sure if it's in "good form" because it is an obscure bit of coding I found here: https://stackoverflow.com/questions/2888976/how-to-make-bat-file-delete-it-self-after-completion `(goto) 2>nul & cd .. & del /q /f "%CurrentDir%\*.bat" & MOVE /Y "%CurrentDir%" "%DestinationDir%"` – StephenE Jun 19 '18 at 20:20

0 Answers0