LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-16-2009, 09:53 PM   #1
ag2uki
Member
 
Registered: Oct 2004
Location: Yogyakarta, Indonesia
Distribution: Mandrake 9.0, 9.1, 9.2, 10.0
Posts: 84

Rep: Reputation: 16
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
 
Old 07-16-2009, 10:00 PM   #2
alienDog
Member
 
Registered: Apr 2004
Location: Europe
Distribution: Debian, Slackware
Posts: 505

Rep: Reputation: 46
Characterset problem. Is it possible for you to rename the file under Windows? That would be the simpliest solution.
 
Old 07-16-2009, 10:05 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,411

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
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.
 
Old 07-16-2009, 10:21 PM   #4
ag2uki
Member
 
Registered: Oct 2004
Location: Yogyakarta, Indonesia
Distribution: Mandrake 9.0, 9.1, 9.2, 10.0
Posts: 84

Original Poster
Rep: Reputation: 16
Unhappy

Quote:
Originally Posted by alienDog View Post
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.
 
Old 07-16-2009, 10:24 PM   #5
alienDog
Member
 
Registered: Apr 2004
Location: Europe
Distribution: Debian, Slackware
Posts: 505

Rep: Reputation: 46
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.

Last edited by alienDog; 07-16-2009 at 10:26 PM.
 
Old 07-16-2009, 10:30 PM   #6
ag2uki
Member
 
Registered: Oct 2004
Location: Yogyakarta, Indonesia
Distribution: Mandrake 9.0, 9.1, 9.2, 10.0
Posts: 84

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by chrism01 View Post
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?
 
Old 07-16-2009, 10:36 PM   #7
ag2uki
Member
 
Registered: Oct 2004
Location: Yogyakarta, Indonesia
Distribution: Mandrake 9.0, 9.1, 9.2, 10.0
Posts: 84

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by alienDog View Post
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"
 
Old 07-16-2009, 10:37 PM   #8
jay73
LQ Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
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.

Last edited by jay73; 07-16-2009 at 10:38 PM.
 
Old 07-16-2009, 11:14 PM   #9
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,074

Rep: Reputation: 386Reputation: 386Reputation: 386Reputation: 386
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.
 
Old 07-19-2009, 09:40 PM   #10
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,411

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
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
 
Old 07-19-2009, 10:21 PM   #11
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
no need for ls
Code:
for file in *
 
Old 07-31-2009, 06:54 AM   #12
tataramu
LQ Newbie
 
Registered: Jul 2009
Posts: 1

Rep: Reputation: 0
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
block special and character special files s_shenbaga Linux - Newbie 4 06-23-2015 03:16 AM
special character tostay2003 Programming 5 01-06-2009 01:39 PM
Really special caracter in filename gabosdenes Linux - General 6 01-02-2008 07:25 AM
Trying to delete a filename with special characters Harry Seldon Linux - General 11 03-20-2007 02:31 PM
special character boolim Linux - General 1 08-29-2003 10:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration