How to Copy Files with Invalid Names on Windows

Windows forbids certain characters in file and folder names: \ / : * ? " < > |. Files created on Linux, macOS, or older file systems often contain these characters, so copying them to a Windows drive fails with an "invalid file name" error.

There are several ways to work around this, depending on whether you have access to the original Linux machine or not.

Option 1: Rename files on Linux before copying

If you have access to the Linux machine, rename the files first to remove or replace the forbidden characters. Most file managers and shell tools (rename, mmv) can do this in bulk.

Option 2: Send files from Linux using LocalSend + TeraCopy

LocalSend is a free cross-platform file transfer app. When you send files from Linux to a Windows PC running TeraCopy, TeraCopy automatically sanitises the names on arrival, replacing each forbidden character:

Original character Replaced with
/ (Unix path separator) \
" (double quote) ' (single quote)
< (
> )
| -
: -
? _ (underscore)
* x
trailing . (period) removed
trailing space removed

The files land on your Windows drive with valid names and no manual renaming needed.

Option 3: Copy via Windows Subsystem for Linux (WSL)

If you don't have access to the original Linux machine, you can mount the source volume in WSL and use Linux tools to rename files before copying them to the Windows filesystem.

  1. Open a WSL terminal.
  2. Navigate to the source folder.
  3. Use rename or a shell script to replace forbidden characters.
  4. Copy the renamed files to your Windows destination.

For a detailed walkthrough, see this guide on wintrouble.wiki.

Option 4: Use a virtual machine

If WSL is not available, install a Linux distribution in a free virtualisation tool such as VirtualBox. Mount the source drive in the VM, rename the files, then transfer them to Windows via a shared folder.

Frequently asked questions

Which characters are forbidden in Windows file names?

Windows does not allow the following characters in file or folder names: \ / : * ? " < > |. Filenames also cannot end with a space or period, and certain reserved names (CON, PRN, AUX, NUL, COM1COM9, LPT1LPT9) are not allowed.

Can TeraCopy rename files automatically on Windows?

TeraCopy sanitises names automatically only when receiving files via LocalSend. When copying directly between Windows paths, it just trims trailing spaces from filenames (the same as Explorer). To fix forbidden characters, rename the files on the source system first.