I have copied some data from my Linux machine to my external hard disk. When I want to read some files on my Windows machine, I can't open it. I get the below error
The specified path does not exist
On the other hand I can't rename or copy the same file, with error
The file name you specified is not valid or too long
I have tried to use rename function in command prompt (with and without quotation marks):
rename "Long Name of The File.pdf" "short.pdf"
but I get this error (I don't know why?):
The syntax of the command is incorrect
Can you please help me?
Best Answer
Without quotation marks or escape characters it won't work, because how can cmd knows which belongs to the original file name and which belongs to the new name? Will
ren old name new name
renames a file namedold
toname new name
or a file namedold name new
toname
or...?Typing by hand might not work either because there may be some hidden or special characters in the file name which you can't type on keyboard. Better type a few characters of the file name and press Tab ↹ for auto-correct until the correct name appears.
If it doesn't work, probably because your path is too long. Rename the folders before the file to make it shorter, or map the containing folder to a drive using
subst
or disk manager mount. For more ways read this and this.You can also try renaming with the short name of the file if it's available. Run
dir /x
to see and check for the short name of the file, then runren shortn.ame new.name
If it still doesn't work, there may be some special characters in the file name that are forbidden in Windows like
/\:*"?<>|
. It might be easier to just boot to Linux and rename it.Further reading: