Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

copy function returns The system cannot find the file specified, when the file exists

Tags:

cmd

copy C:\Users\MinCarve\documents\visual studio 2017\Projects\PROGRAM\Debug\PROGRAM.exe 
     C:\Users

returns

The system cannot find the file specified. when the executable exists in that directory!

like image 621
MinCarve Avatar asked Oct 25 '25 04:10

MinCarve


2 Answers

The path of your file has a space in its name, which means you have to surround the path which contains spaces with quotation marks.

like image 61
sininen Avatar answered Oct 26 '25 23:10

sininen


copy C:\Users\MinCarve\documents\visual studio 2017\Projects\PROGRAM\Debug\PROGRAM.exe C:\Users

has FOUR parameters. It tries to copy
C:\Users\MinCarve\documents\visual (which does (probably) not exist) to the location
studio (which (probably) doesn't exist too, and two more parameters:
2017\Projects\PROGRAM\Debug\PROGRAM.exe
C:\Users

Copy stops with the first error found, in this case, C:\Users\MinCarve\documents\visual does not exist.

Solution: quote parameters that contain one or more spaces. Best practice: do it anyway: copy "source" "destination".

copy "C:\Users\MinCarve\documents\visual studio 2017\Projects\PROGRAM\Debug\PROGRAM.exe" "C:\Users\"
like image 37
Stephan Avatar answered Oct 26 '25 23:10

Stephan