How to fix ERROR_INVALID_NAME (123)
Description
The filename, directory name, or volume label syntax is incorrect.
Causes
- Invalid Characters: The file or directory name contains characters that are not allowed (e.g., \ / : * ? " < > |).
- Name Too Long: The file or directory name exceeds the maximum length allowed by the file system.
- Reserved Names: The name used is reserved by the system (e.g., CON, AUX, PRN, NUL).
- Incorrect Path Format: The file path is incorrectly formatted or contains invalid syntax.
- Trailing Spaces or Periods: The name ends with spaces or periods, which are not allowed in Windows.
Solutions
Verify and Rename File or Directory
Ensure the name does not contain invalid characters or reserved names. Rename the file or directory by right-clicking it, selecting "Rename," and providing a valid name.
Copy files using Windows Subsystem for Linux
Names with characters Windows forbids - such as : and " - are fine on Linux. WSL can copy or move that data when Explorer or cmd refuse.
Under /mnt/…, DrvFs maps those names onto NTFS, so tools like cp often work between drives even when Windows would block the same path; in Explorer the names may show odd substitute characters.
- Install WSL from an elevated PowerShell window (reboot if the installer asks you to):
wsl.exe --install
- Confirm the source drive is mounted (replace
dwith your drive letter, lowercase):
ls -la /mnt/d
-
On Windows, create the destination folder (for example C:\Import) if it does not exist yet.
-
Copy everything from D: to C:\Import (adjust letters and the target path as needed):
sudo cp -av /mnt/d/. /mnt/c/Import/
If a copy still fails, stage files under your Linux-native home (for example ~/import-staging), rename them to plain Windows-safe names, then copy into C:\Import.
Shorten the File or Directory Name
If the name is too long, shorten it to meet the maximum length allowed by the file system. For example, NTFS supports up to 255 characters for file names.
Correct the File Path
Double-check the file path for any syntax errors or invalid formats. Ensure that the path is correctly structured and does not contain illegal characters.
Remove Trailing Spaces or Periods
Ensure that the file or directory name does not end with spaces or periods. Rename the file to remove any trailing spaces or periods.