LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Help me into how to change directory into a non-alphanumeric named folder (https://www.linuxquestions.org/questions/linux-software-2/help-me-into-how-to-change-directory-into-a-non-alphanumeric-named-folder-4175578095/)

jheengut 04-22-2016 05:57 AM

Help me into how to change directory into a non-alphanumeric named folder
 
how to change directory into a non-alphanumeric typed folder
Code:

ls -a|cat -A
.$
..$
Services.xlsx$
System Volume Information$
M-BM- $

The last folder cannot be typed in using a keyboard.

Is there a way to change the folder name?

HMW 04-22-2016 06:38 AM

Quote:

Originally Posted by jheengut (Post 5534960)
how to change directory into a non-alphanumeric typed folder
Code:

ls -a|cat -A
.$
..$
Services.xlsx$
System Volume Information$
M-BM- $

The last folder cannot be typed in using a keyboard.

Is there a way to change the folder name?

?

Do you mean the directory:
"M-BM- "

Why can't you type that? Use \ before a blank space. Like this:
Code:

cd M-BM-\
To rename it:
Code:

mv M-BM\ / foo
Or am I missing something?

Best regards,
HMW

rtmistler 04-22-2016 09:50 AM

Given that M-BM-<whatever> is unique from the other directory names, also use a wildcard:
Code:

mv M-BM-* <new-name>

Habitual 04-22-2016 10:04 AM

Since there are no "folders" in Linux. (They are all files.)
"Folders" is a graphical term for files...why not just deal with it graphically?

Doug G 04-22-2016 12:17 PM

mc from the command line can often deal with weird file/directory names that are difficult to type.

lazydog 04-22-2016 12:32 PM

Does
Code:

cd M-<tab>
not work?

rtmistler 04-22-2016 12:38 PM

Quote:

Originally Posted by lazydog (Post 5535086)
Does
Code:

cd M-<tab>
not work?

This is along the lines of my recommendation. That name appears to be unique, use the wildcard or TAB for completion and then change the name to something which is not a problem.
Quote:

Originally Posted by Habitual (Post 5535033)
Since there are no "folders" in Linux. (They are all files.)
"Folders" is a graphical term for files...why not just deal with graphically?

I also was thinking this too. Just in whatever form of file manager there is, right click, rename, ... boom, done :)

I guess it boils down to if there's something left out by the OP that we're missing here.

jamison20000e 04-22-2016 12:42 PM

Who may only have a CLI (like me 10% of the time:)
...quotes may help?
Code:

cd "M-BM- "
Have fun! :D

Habitual 04-22-2016 03:45 PM

Quote:

Originally Posted by rtmistler (Post 5535089)
I guess it boils down to if there's something left out by the OP that we're missing here.

And there's always "more" to the story than some 20 some-odd word post.

System Volume Information$ is certainly a big "tell".

jheengut 04-26-2016 06:37 AM

Hi guys,

Sorry to be a bit late.

the output of ls gives just some folder name some are printable while one is not printable on the terminal .

But if I pipe the output of ls into cat -A, the non-printable characters' of the file name is output as

Code:

M-BM- $
This file name cannot be typed in using a normal keyboard and I forgot to get the hexadecimal number of the non-printable characters.

Still I managed to use nautilus in a ubuntu virtual machine to rename the folder.

The weird name arose due to a virus on a crappy windows shitty laptop. It managed to hide some files into a non-printable folder.
Even power shell was unable to print the filename.
Unfortunately, My slackbox was not with me at that particular place and time.

keefaz 04-26-2016 08:01 AM

You could manipulate directory file with inode number instead of name
find the inode number
Code:

ls -i
Then rename the directory using find
Code:

find . -maxdepth 1 -inum $inode_number -exec mv '{}' "new directory name" \;


All times are GMT -5. The time now is 01:56 PM.