0

I built a new computer from ebay scraps after my laptop died. I began transferring files from my old hard drive (Windows XP to Windows 10) and ran into an issue where I could not either move or delete some of my old files. I received an error that file names were too long.

  1. First I tried renaming the files.

    Result: For some reason, the files would not rename. I checked and they were not Read Only...A weird mystery.

  2. I researched this forum and changed Windows to accept Long File Paths.

    Result: While the long file paths were a contributing factor, the real issue were the names of the files themselves. I still couldn't move or delete these files.

There had to be some legacy setting that allows long file names (example: royalty-free-photograph-of-student-chemistry-biology-bottle-science-BGBB5A)

The question is this: Is there a legacy setting in Windows 10 that will allow me to work with these files?

Craig
  • 1
  • 1
  • 1
  • 7-Zip can rename the long files – AllenBooTung Mar 25 '20 at 02:21
  • `royalty-free-photograph-of-student-chemistry-biology-bottle-science-BGBB5A` is not long at all. It's long compared to DOS 8.3 names but is far from Win32 limit of 255 characters. The issue is long file **path**, not long file **name**, which the built-in robocopy can handle without any problem – phuclv Mar 25 '20 at 03:52
  • just add the \\?\ prefix with `copy` command, or use another tool to copy. There are lots of duplicates: [How to copy files that have too long of a filepath in Windows?](https://superuser.com/q/216704/241386), [Copying from one drive to another / filename too long?](https://superuser.com/q/1355853/241386), [How to prevent long file name error copying from an external drive?](https://superuser.com/q/349531/241386)... – phuclv Mar 25 '20 at 04:00
  • 1
    Does this answer your question? [How to copy files that have too long of a filepath in Windows?](https://superuser.com/questions/216704/how-to-copy-files-that-have-too-long-of-a-filepath-in-windows) – phuclv Mar 25 '20 at 04:00

2 Answers2

3

You should be able to manipulate them using the old 8.3 filename, which is available from CMD. For example, enter dir / at root and you should see the following.

CMD to manipulate long filenames

You can perform operations such as copy or delete on PROGRA~2, a synonym for Program Files (x86), for example.

You can also use wild cards, particularly helpful where a filename has an illegal character.

That said, often the issue is an excessively long path, i.e. drive + full file path + filename longer than 260 characters. You can make Windows 10 handle longer paths by setting the Registry value LongPathsEnabled in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem to 1, or back to 0 to revert behavior.

  • Press Windows, type rege and select Regedit.
  • Accept the UAC prompt.
  • In the location bar, enter HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem (copy and paste from here to make it easier) and press Enter.
  • If the value LongPathsEnabled does not show in the right pane, right-click, select New> New DWORD (32-bit) Value, and copy the value name above.
  • Double-click the value and set it to 1.
DrMoishe Pippik
  • 25,661
  • 4
  • 36
  • 54
0

My workaround (Windows 10) was to 1) enable long file paths in Windows and 2) use the WSL2 bash command cp -R to do the actual copying. (I am not sure if step 1) was necessary, but the combination worked for me).

Bobby
  • 1
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 03 '23 at 00:40