LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Filename contains special character (https://www.linuxquestions.org/questions/linux-newbie-8/filename-contains-special-character-740656/)

ag2uki 07-16-2009 08:53 PM

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

alienDog 07-16-2009 09:00 PM

Characterset problem. Is it possible for you to rename the file under Windows? That would be the simpliest solution.

chrism01 07-16-2009 09:05 PM

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.

ag2uki 07-16-2009 09:21 PM

Quote:

Originally Posted by alienDog (Post 3610209)
Characterset problem. Is it possible for you to rename the file under Windows? That would be the simpliest solution.

Of course it is possible. But it is not simpliest solution at all because i have to go to a place 3 kilometres far away from my place right now just to find windows machine and rename a file. :scratch:

alienDog 07-16-2009 09:24 PM

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.

ag2uki 07-16-2009 09:30 PM

Quote:

Originally Posted by chrism01 (Post 3610216)
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.

I have already tried it.
$ 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:

ag2uki 07-16-2009 09:36 PM

Quote:

Originally Posted by alienDog (Post 3610229)
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.

Thanks all for your reply.
I have tried it too. It still returns "No such file or directory"

jay73 07-16-2009 09:37 PM

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.

i92guboj 07-16-2009 10:14 PM

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.

chrism01 07-19-2009 08:40 PM

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
IFS="
"
for file in `ls`
do
    # derive/create a sane name for $file, then rename
    mv $file <sane_name>
done


ghostdog74 07-19-2009 09:21 PM

no need for ls
Code:

for file in *

tataramu 07-31-2009 05:54 AM

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.