How tp copy, not overwrite, and not prompt?

August 24, 2009 at 17:46:22
Specs: Windows XP

Hi,

How can I copy files, not overwrite existing
files, and not prompt?

I see how to do this with overwriting but not
without.


See More: How tp copy, not overwrite, and not prompt?

Report •


#1
August 24, 2009 at 18:16:03

What are you trying to do?

If you are trying to copy a file into a folder where a file of the same name already exists you have to choices. Either overwrite the existing file or abort the copy and do nothing. You cannot have two files with the same name in the same folder.

Without the prompt you WILL ovrwrite the exisitng file which is probably what you dont want.

Stuart


Report •

#2
August 24, 2009 at 18:16:03

What are you trying to do?

If you are trying to copy a file into a folder where a file of the same name already exists you have to choices. Either overwrite the existing file or abort the copy and do nothing. You cannot have two files with the same name in the same folder.

Without the prompt you WILL ovrwrite the exisitng file which is probably what you dont want.

Stuart


Report •

#3
August 24, 2009 at 19:09:11

I am trying to copy a directory of files but I would only like to
copy files which do not exist in the destination directory.

Report •

Related Solutions

#4
August 24, 2009 at 20:57:57

Here is a VBScript to do it, this script will not overwrite existing files, All you have to do is change the two variable's strSourceDir and strDestinDir. Copy the script into a .vbs file and run it. Side note, *.* in the source will copy all files of any type from the source dir, if you want to only copy *.txt or whatever modifie accordingly, also the destination directory must end with a "\" so that the script knows that it is a folder. IF you want to overwrite existing files all you have to do is change the const overwriteexisting from False to True.

Option Explicit
Dim strSourceDir, strDestinDir, FSO
const OverwriteExisting = False

strSourceDir = "C:\test1\*.*" 'change this line
strDestinDir = "C:\test2\" 'change this line

on error resume next
set FSO = CreateObject("Scripting.FileSystemObject")
FSO.CopyFile strSourceDir , strDestinDir , OverWriteExisting


Report •

#5
August 25, 2009 at 08:21:41

There must be a simple command to do the exact opposite of

xcopy /u source\* dest\

Since I can't find such a command, here is a batch script (use either this one or gtaion's VBScript):

for %%a in (source\*) do (
   if not exist dest\%%~nxa (
      copy %%a dest
   )
)


Report •


Ask Question