CMD "MOVE /Y" asks for confirmation

Viewed 41120

I'm still working on getting this: CMD for unable to move files due to string butchering to work.

My batch script looks like this right now,

FOR /F "delims=" %%T IN ('dir G:\ /B /A:D') DO (
  CD "G:\%%T"
  FOR /R %%D IN (*) DO (MOVE /Y "%%D" "G:\%%T")
)
PAUSE

and does as I intended, however as soon as it finds a duplicate file, it asks what it's supposed to do (overwrite: yes/no/all) for EACH file. Ordering to replace ALL only replaces one file.

Image: http://imgur.com/aKLsKs1

Why does it do that, and how do I fix it?

EDIT: Turns out to be a windows bug of sorts. ROBOCOPY or XCOPY both work and their quiet switches work.

4 Answers

since windows 2000, the behaviour of the command is to prompt for confirmation regardless of the /y switch, unless the command is triggered from a script.

you can override this by setting the environment variable COPYCMD to /Y before running your move command. eg: SET COPYCMD=/Y && move /Y a b

this behaviour is documented at: https://ss64.com/nt/move.html

Related