2

I wanted to make a windows command line script that moves all of the user data into a folder. I stared with moving all the files from the desktop into a folder Its working with xcopy but i revive some errors while using move.

@echo on
set SOURCE=C:\Users\%username%\Desktop
set DESTINATION=C:\dir2
xcopy "%SOURCE%\*" "%DESTINATION%\*"  /y
pause

This works with xcopy but when I change it to move the syntax breaks. Why is it happening?

Rishav
  • 3,818
  • 1
  • 31
  • 49
  • xcopy is the right tool for the job. You can use move, if you wish to simply move an entire folder. However, you're not going to be able to move the Desktop folder. You can move folders within it though. – ManoDestra Jun 07 '16 at 20:47
  • this may help you: http://stackoverflow.com/questions/4743094/how-can-i-move-all-the-files-from-one-folder-to-another-using-the-command-line – Mahendra Kulkarni Jun 08 '16 at 07:39

2 Answers2

1

There is a minor glitch in your code.
You can't use the asterisk (*) placed after the %Destination% while moving. Instead use the following code. If you don't want a prompt use /Y

@echo on
set SOURCE=D:\old
set DESTINATION=D:\new
move /Y "%SOURCE%\*" "%DESTINATION%\" 
pause
Rishav
  • 3,818
  • 1
  • 31
  • 49
0

For the MOVE command, the /Y option has to be specified before the source file names.

So instead, use :

move /Y "%SOURCE%\*" "%DESTINATION%\*"
Filipus
  • 520
  • 4
  • 12