Filename contains special character
Dear all member,
I have a file from my usb flash disk. Its name consists of special character that my filebrowser cannot read correctly. On my windows system it shows as Document™.zip. But my linux shows Document?.zip. Note that there is a small (TM) symbol in its name. This miss-naming can not make me do anything on this file in linux. I have tried to open or copy it to my local hard drive, but it always shows me a message "no such file or directory". I've tried to copy it using console, but the same problem still occurs. How do i solve this problem? Any suggestion? regards |
Characterset problem. Is it possible for you to rename the file under Windows? That would be the simpliest solution.
|
You could try using ls on the filename and then cp, putting single quote marks around the name.
You should rename it though, it'll always be a pain otherwise. |
Quote:
|
Maybe bash autocomplete would help? Try this in console:
mv 'Docume Then hit the tab key to complete the filename, then add another single quotation mark and complete the mv command (i.e. enter a new name for the file and hit enter). Not sure if this will work, just an idea. Could be worth a shot. |
Quote:
$ cp 'Document?.zip' ~/ cp: cannot stat 'Document\?.zip': No such file or directory But it always shows "no such file or directory". How could I rename it if I cannot get its name correctly? :scratch: |
Quote:
I have tried it too. It still returns "No such file or directory" |
The single quotes make the ? a literal; do it without single quotes. Also, you may prefer * over ?, although, technically, the trademark symbol is indeed a single character.
|
Setting the right charset at mount time might help. How to do that strongly depends on the fs where that file lives.
For example, if it's a fat fs and you are mounting it in linux as vfat, you should check the fat section on the manual page for the "mount" command. Specially, the codepage and iocharset options. For other file systems, the options might vary. Supposedly, as long as the charset and codepage info is right, the you should see the files *perfectly* just like in Windows. However, my experience with windows drives on linux is quite limited, so I wouldn't dare to swear by it. |
another option is this:
1. move all ok named files to another dir 2. write a loop like Code:
# make default IFS a newline only ie hit the rtn key once, between double quotes |
no need for ls
Code:
for file in * |
You should be able to access the file name by giving \ before ? symbol.
Ex: To list file: ls -ltr Document\?.zip or To rename the file, u could do, mv Document\?.zip Document.zip |
All times are GMT -5. The time now is 11:50 AM. |