I want to copy a folder full of folders to a backup on another disk. But if a duplicate filename already exists on the other disk, I want Windows to prompt to ask whether or not to replace the file for each file separately.

Windows XP just gives me the option to replace all of the files or not copy the folder. Only if I copy only one folder will it prompt individual files. There are hundreds of folders in this structure, but less than 100 duplicate file names. But I don't know where the duplicates are, and do not know their filenames.

The problem is that I receive a lot of files submitted by students for grading. They are in a structure of subfolders named for the student name, all in a master folder on the assignment collecting system (which appears on my workstation as a drive). On each assignment due date, I want to copy the structure and files to identical folder structures of the work already received on two different hard disks. After I do this, I can click an icon to delete the files on the collection system but leave the structure. But there are always several cases where duplicate filenames arise, and I must manage each case separately.

  • A. The student submitted two different assignments at different times using the same filename.

  • A. The student modified the assignment file and submitted it again after I deleted the original.

  • B. The student submitted the same file again after I deleted it from the collection system.

  • B. I was unable to delete a file from the collection system earlier because it was open.

  • C. I received a partial copy of the file earlier because it was open.

In cases A, the new file must be renamed so both can coexist.
In cases B, the new file is deleted.
In cases C, the new file must replace the old one.

All I really need to do at copying time is deny the replacement when copying to one drive, and write down the file path. Then I can manage it later before copying the structure to the second drive and the file to the first drive.

As an alternative, I want a way that searches both sets of folders for duplicate names in the same place in both structures and reports them to me, so I can manage them before I do any copying.

Answers I do not want:
- Change operating systems - I don't control this
- Download or buy someone else's software - Not allowed
- A complicated system of - Must be easy for others to do
- Moving each folder separately - Can take hours
I give down points to these answers.

Dani AI

Generated

— given you cannot install anything, and after the suggestions from (Cygwin/cp) and (xcopy/shortcut), a small Windows Script Host script gives the behavior you want without extra software. The script below walks your source tree, creates matching folders on the destination, and whenever a file already exists it shows a GUI prompt that includes both files' sizes and last-modified times. You can choose to overwrite, skip, rename (keep both), or log the conflict for later. Put the .vbs on the desktop so others can double‑click it (it runs under WScript and shows dialogs).

Edit the two lines at the top to set source and destination, test on a small sample first, and confirm you have read/write permissions to both drives. The script writes a simple conflicts.log in the destination root so you can handle recorded cases later. If you prefer, run the script twice (once for each backup drive) so you can deny replacements on the first backup and then resolve them before copying to the second.

Example VBScript (drop as copy_prompt.vbs, change srcRoot/dstRoot, double‑click to run):

' copy_prompt.vbs -- edit srcRoot and dstRoot then double-click to run
srcRoot = "J:\Master"    ' change to your source root
dstRoot = "K:\Backup"    ' change to your destination root

Set fso = CreateObject("Scripting.FileSystemObject")
Set src = fso.GetFolder(srcRoot)
WalkFolder src, dstRoot

Sub WalkFolder(srcFld, dstFld)
  If Not fso.FolderExists(dstFld) Then fso.CreateFolder(dstFld)
  For Each f In srcFld.Files
    dstFile = fso.BuildPath(dstFld, f.Name)
    If fso.FileExists(dstFile) Then
      Set df = fso.GetFile(dstFile)
      msg = "Conflict:" & vbCrLf & f.Path & vbCrLf & vbCrLf & _
            "Source: " & FormatSize(f.Size) & "   " & CStr(f.DateLastModified) & vbCrLf & _
            "Target: " & FormatSize(df.Size) & "   " & CStr(df.DateLastModified) & vbCrLf & vbCrLf & _
            "Type Y to overwrite, N to skip, R to rename and keep both, L to log and skip"
      choice = UCase(Left(Trim(InputBox(msg,"File conflict","N")),1))
      Select Case choice
        Case "Y"
          fso.CopyFile f.Path, dstFile, True
        Case "R"
          newName = MakeUnique(dstFld, f.Name)
          fso.CopyFile f.Path, fso.BuildPath(dstFld, newName), False
        Case "L"
          LogConflict f.Path, dstFile
        Case Else
          ' skip
      End Select
    Else
      fso.CopyFile f.Path, dstFile, False
    End If
  Next
  For Each sf In srcFld.SubFolders
    WalkFolder sf, fso.BuildPath(dstFld, sf.Name)
  Next
End Sub

Function MakeUnique(folder, fname)
  dotPos = InStrRev(fname, ".")
  If dotPos > 0 Then base = Left(fname, dotPos-1) : ext = Mid(fname, dotPos) Else base = fname : ext = ""
  ts = Year(Now) & Right("0" & Month(Now),2) & Right("0" & Day(Now),2) & "_" & Right("0" & Hour(Now),2) & Right("0" & Minute(Now),2) & Right("0" & Second(Now),2)
  newname = base & "_" & ts & ext
  Do While fso.FileExists(fso.BuildPath(folder, newname))
    newname = base & "_" & ts & "_" & CInt(Rnd*1000) & ext
  Loop
  MakeUnique = newname
End Function

Function FormatSize(b)
  If b < 1024 Then FormatSize = b & " B" ElseIf b < 1048576 Then FormatSize = FormatNumber(b/1024,2) & " KB" Else FormatSize = FormatNumber(b/1048576,2) & " MB"
End Function

Sub LogConflict(src, dst)
  log = fso.BuildPath(dstRoot, "conflicts.log")
  Set tf = fso.OpenTextFile(log, 8, True)
  tf.WriteLine Now & " | " & src & " -> " & dst
  tf.Close
End Sub

Troubleshooting notes: test first; run as a user with write access to the destination; very long paths or unusual characters can need handling; if a target file is read-only the copy will fail — clear the attribute or change the script to remove attributes before overwrite. This approach meets your “no installs” requirement and gives the per-file metadata and choices you asked for.

Recommended Answers

All 9 Replies

Unfortunately, unless you violate Answers #2 (download someone else's software) I can't help you; however, if you can install Cygwin (a Linux environment for Windows), then you can do this, and very easily. You would use the copy -ri dir1/* dir2 command/format which will copy all of the contents of dir1 into dir2, and ask you if you want to overwrite duplicate files (of the same name). This command (cp) is a standard part of cygwin (and Unix/Linux). It is a command-line function, and does not have a GUI component...

I do not have authority to install anything on the workstations.

There is a similar DOS function called xcopy that is installed. I will look into that.

Is there a way to make a call to it with a gui icon in XP?

I got it to work, but I have to use the DOS screen. This means that I have to do the bacvkups myself, because others can't just click and do it.

The command is:

xcopy j:/*.* k: /e /q /-y

If that command is doing just what you wish, then put it into a desktop shortcut.
Rclick desktop, New, Shortcut, paste in your command, Next to name it. Done.
A cmd window will flash, but that's hard to stop without using WSH.

Does it use the cmd window to ask about replacements, or does the Windows copy window apopear? The cmd window does not tell me the sizes or dates of the files.

Ah... of course, you want the copy dialogue for files existing in the target. So this is the cmd to put into your shortcut:

%comspec% /k xcopy.exe j:\*.* k:\ /e /q /-y

%comspec% will open the cmd window; the /k will keep it open after all copying is done so you can see the summary, else a /c will close the window immediately copying is over - you need one or the other.
I have put a \ after your target so that xcopy knows it to be a directory.
You don't actually need %comspec% to run xcopy.exe because it is an external command, but it will run it, of course, and it shows you the copying dialogue you require.

You can append commands in there, too, but you must be careful with syntax; a space or no in the wrong place and the string won't work. So:

%comspec% /k title Student Folders Updater & xcopy.exe j:\*.*" k:\ /e /q /-y

Now your window has a title, not just the command string it is executing.

I asked where the prompts for whether or not to replace will appear, not how to make the command window appear. The user will have to answer each prompt with Y or N.

Also, I need a way to see the sizes and file creation dates of the two files before each prompt, so I know whther or not to answer Y or N. The Windows copy a single folder provides that, but xcopy does not.

"Ah... of course, you want the copy dialogue for files existing in the target. So this is the cmd to put into your shortcut:"
And that was my answer to your request. Gee, just try it with some folders and files and a dummy target. But if you wish the dialogue to appear elsewhere than the cmd window then xcopy is not your command, and cmd is not the environment to use.
"Also, I need a way to see the sizes and file creation dates". Yes, possible with copy cmd, but you will need to invoke other commands to copy folders, and so a simple batch file will be required at the very least, and the dialogue will still appear in the cmd window.
Anyway, I was just following on from your mention of std Windows XP commands. Me, I'd use Richcopy and fully automate the process, no need to study individual overwrites. If you cannot/are not permitted to download that command from Technet then I cannot help further [it isn't supported by M$, but is written by one of their software engineers. Heck, it installs as Microsoft Richcopy]. It's pinned to my Start Menu; if drag n drop doesn't cut it [as it does not for you] then Richcopy gets the job. Runs on XP, is blindingly fast and can remember your task options.
Syncback also would work for you, present a list only of duplicates and their specific differences, and request actions.
Not much more I can offer. I don't care if you down-vote me for those answers. I don't give a hoot about such; it has no meaning for me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.