Quantcast
Channel: What is the windows command line command to copy files? - Server Fault
Viewing all articles
Browse latest Browse all 8

Answer by Graeme Perrow for What is the windows command line command to copy files?

$
0
0

In a batch file:

if not exists locationB\nul mkdir locationB
copy locationA\file locationB

if not exists checks the parameter to see if it exists, but it only works on files. To check for existence of a directory, you need to look for a 'pseudo-file' called "nul" - checking for existence of this file will always return true if the directory exists.

The copy line copies the file called file in directory locationA to locationB and names the file the same thing. If you want to rename the file at the same time, you can do that too:

copy locationA\file locationB\newfilename

Viewing all articles
Browse latest Browse all 8

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>