1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Parse filenames that have embedded spaces

Discussion in 'Suggestions' started by Margaret, Apr 3, 2013.

  1. Margaret

    Joined:
    Apr 3, 2013
    Messages:
    5
    Likes Received:
    0
    Having to pre-process filenames that have embedded spaces in order to do a move or copy is annoying. It shouldn't be difficult for the shell to parse them correctly (I mean, Microsoft does it, so how hard can it be?)
     
  2. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,304
    Likes Received:
    39
    Not hard at all. Just use double quotes around any filename that contains spaces, or that might contain spaces.
     
  3. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,856
    Likes Received:
    83
    Microsoft (i.e., CMD.EXE) does it the same way as TCC / TCMD, by putting double quotes around the filenames. When a command accepts multiple arguments, it's beyond the scope of a command line parser's abilities to decide when a space is a delimiter and when it isn't.
     
  4. Margaret

    Joined:
    Apr 3, 2013
    Messages:
    5
    Likes Received:
    0
    I wasn't really thinking of cmd.exe since with tc I rarely have a need for it, but rather the explorer or whatever its name is. It gets away with it because it already knows what the paths and filenames are (I thought tc was going to have a similar interface, actually--I still don't know what the functional diffs are between 4nt and tc).

    But a cli like tc can figure things out 80% of the time or more by looking at the disc. It would slow things down by one or more extra reads, but a lot of that overhead could be reduced heuristically by caching the pointless embeddings that we get from Microsoft for our inconvenience ("Program Files", etc). When it can't figure it out, do what tcsh does: ask.
     
  5. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,304
    Likes Received:
    39
    If you use tab completion, TCC (or CMD.EXE, for that matter) will pick up the filename from the disk and add quotation marks as needed. Get into the habit of using the Tab key; it saves a whole lot of typing and reduces errors, too.
     

Share This Page