geekvenue.net

Welcome to Chucktips Hardware HELP WITH DEAD OS Installing FreeBSD Miscellaneous
 faq
 search
 add article
 cool-stuff
 how-to
 main
 tips


TIP: using spaces in filenames
Miscellaneous Posted by Jason on Wednesday January 09, @03:55PM
from the back-slash-space dept.
If you have a directory name which contains spaces, you can use the cd (change directory) command to change to those directories. You can also manipulate files when their name contains spaces.

All you have to do to work with these files and directories is use a \{space} to represent the actual space in the name.

Example:
If you keep all your mp3 files by the name of the Artist and the name of the Album, your directory structure might look like this:

/mp3/
/mp3/Lou Reed
/mp3/Lou Reed/New York
/mp3/Lou Reed/New York/track1.mp3

If you wanted to cd to the New York directory and change the name track1.mp3 to the name 1 - Romeo had Juliet.mp3 you would have to use the the \{space} like so:


[Changing Directories]

# cd /mp3/Lou\ Reed/New\ York
# pwd

/mp3/Lou Reed/New York


[Renaming the File]

# mv track1.mp3 1\ -\ Romeo\ had\ Juliet.mp3
# ls

1 - Romeo had Juliet.mp3


[Using wild cards]

You can also use wild cards * to simplify changing directories. If you have a directory like so:

/mp3/Grateful Dead/What a long strange trip its been/

You may not want to do all the \{space} typing. In this case here is what I would do:

# cd /mp3/Grat*/What*
# pwd

/mp3/Grateful Dead/What a long strange trip its been


As a general rule I always recommend reading the man pages for all unix commands. However, the man page for cd is quite slim and has no reference to working with spaces.

man cd
man mv
man pwd


<  |  >

 

Related Links
  • Articles on Miscellaneous
  • Also by Jason
  • Contact author

    If you have ever wanted to learn about Cisco Routers, check out my new book "Cisco Routers for the Small Business" - it's Cisco CLI for the Regular Guy!

  • Sponsors

    The Fine Print: The following comments are owned by whoever posted them.
    ( Add a Reply )

    Re: TIP: using spaces in filenames
    by Leon Dang on Thursday January 17, @05:24PM

    Knowing your quotes also helps. I often use quotes in my command lines. Double quotes are used when you want the ability for environment variable substitution, single quotes are when you want to retain everything as is.

    FreeBSD's tcsh shell also allows for TAB name completion (although I find bash's name completion easier to use), so typing out long names won't be painstaking as it once was long ago.


    [ Add a Reply to this ]
    The Fine Print: The following comments are owned by whoever posted them.
    ( Article Reply )

    "You never know how many friends you have until you own a Condo on the beach." -- Jason's Postulate

    Powered by Zope  Powered by Apache  Squishdot Powered
    All trademarks and copyrights on this page are owned by their respective companies. Comments are owned by the Poster. The Rest ©2001 Jason Neumann.
    [ main | post article | search ]