1

I have an encapsulated Windows 10 Kiosk system that creates/provides reports on external USB storage devices (NTFS). Unfortunately there's not a lot I can say about this system as it is fairly well tied down.

When I place that USB storage device on another Windows system (Windows 10 Pro 19044.1387 ) in order to copy/backup I run into some issues.

In one the the report subfolders (images) all the picture files are stored. When attempting to copy this folder to a new location (where nothing preciously exists) I am prompted by Windows to choose to what to do regarding over writing existing files. There shouldn't be any!

Looking in the source folder I can see there are indeed some files with identical names. For example multiple "Image-1.jpg" files. The contents of these files are all visually different. There are no brackets "()" with counts in any of these files.

I originally suspected hidden control characters that the copy was probably stripping away resulting in the duplication, but I could not identify such characters. Not saying this is not the case, I just couldn't easily identify such.

However now I cannot copy the report in its entirety.

What options are left to me to copy/backup this report and maintain the duplicate files with identical names? Can I force Windows to create another file with the same name in the same folder?

UPDATE:

I found the hidden character. It turns out to be a leading " " (space). One file is call "Image-1.jpg" the other is " Image-1.jpg" the Windows copy must be stripping leading spaces and causing a conflict in names where none exist. (Assuming you may start a file name with a leading space)

I just tried to create a txt file from Windows and it doesn't let you create a file with a leading space but from the cmd/dos prompt you can. $ echo abc >" my file.txt" creates a file with a leading space that can be viewed from file explorer.

From Windows File Explorer you cannot rename and remove the leading space as it claims the file names are identical. You must completely give it a new name then change it back to the original name minus the leading space.

So my guess that Windows copy was removing hidden characters is correct. A file name with a leading space matches the same file name without that space so if both are in one folder when that folder is copied they will conflict with each other.

Using the following dos commands to test this issue:

$ mkdir "test"
$ cd test
$ echo "abc" >"file1.txt"
$ echo "def" >" file1.txt"

Then use File Explorer to copy the test folder and you will see it renames one of the files. However it will only automatically rename the file if there is no other conflict with "- Copy". If there is a conflict then you will get prompted what to do.

4
  • 1
    Windows can't have 2 files with exactly the same name in the same folder. How are these files stored in the usb is there something like a container file like rar, zip or 7z file where the files are stored inside this container? Dec 29, 2021 at 6:24
  • I thought the same as you, that this shouldn't happen in Windows. No containers or archives involved. I think there may still be a hidden character in the filename! Dec 29, 2021 at 6:43
  • Can you enter this image folder from the command prompt and do a dir /b and show a screenshot from some of the duplicates? Dec 29, 2021 at 6:56
  • I agree with user1654333's answer. Windows File Explorer can change the names of files when copying even when there are no conflicts with names because it assumes files cannot start with a space and so it trims leading spaces (I haven't checked trailing) and with or without warning changes the file name. That's two issues. 1. Assumes non leading spaces. 2. May rename a file without warning. (I was lucky it couldn't rename because all "- copy" type names already existed. Otherwise it would have broken the report by renaming referenced files) Dec 29, 2021 at 7:15

1 Answer 1

1

You seem to have run into a File Explorer bug. However, PowerShell 7.x and Windows PowerShell don't seem to have this bug.

I created a "Test" folder on my Desktop, containing two files: " 1.jpg" and " 1.jpg". Then, I copied the contents of "Test" into "Test2" using the following command:

Set-Location '~\Desktop'
Copy-Item 'Test\*' 'Test2'
1
  • In the end good ol robocopy to the rescue!!! Dec 29, 2021 at 23:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .