1

In Linux, how can I recursively copy files and directories in such a way that all of the copied files and directories will have a name that windows can handle?

I want to copy a folder into a shared directory or USB device that uses Windows file name restrictions, without failing or losing any files/folders (prefer to change name rather than to lose data).

3
  • If a device "uses Windows file name restrictions", this means the filesystem there uses restrictions. But Windows programs may be more restrictive. Compare this or this. Windows itself can handle many problematic names (using \\?\…) but this is inconvenient in daily use. Sets of names that "device (filesystem) can hande", "Windows can handle" or "common Windows programs can handle" differ. It's not really clear which one you want. Commented Oct 19, 2019 at 8:14
  • @KamilMaciorowski I want to copy the files without losing them. I don’t care if they won’t work with some application. Commented Oct 19, 2019 at 8:16
  • 1
    But even printing a directory listing or copying files further on Windows is done by "some applications" (e.g. explorer.exe). OK, let me rephrase: is Windows involved at all? (what Windows then?) Or you just need to store files on a non-Linux filesystem (what filesystem?) and still use them with Linux only. Commented Oct 19, 2019 at 8:37

1 Answer 1

0

Some ideas from the post copy filenames with special characters to an external ntfs volume:

  • Use detox to clean up special characters in filenames.

  • Mount the NTFS filesystem so it cleans up (sanitizes) the file names by itself. The mount option to enable this is windows_names. See man ntfs-3g.

  • Use rsync to change filenames to fit the destination filesystem with the parameter --iconv=CONVERT_SPEC, to request charset conversion of filenames.

You must log in to answer this question.

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