Parse filenames that have embedded spaces

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
Apr 3, 2013
5
0
#1
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?)
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,385
39
Albuquerque, NM
prospero.unm.edu
#2
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?)
Not hard at all. Just use double quotes around any filename that contains spaces, or that might contain spaces.
 

rconn

Administrator
Staff member
May 14, 2008
10,101
85
#3
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?)
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.
 
Apr 3, 2013
5
0
#4
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.
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.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,385
39
Albuquerque, NM
prospero.unm.edu
#5
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.