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