Re: RENAME problem: directories with spaces?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Juergen Luethje wrote:
> 
> Dan Moyer wrote:
> 
> > Juergen's suggestion for using "rename" with "system" command,
<snip>
 > seems like it should have worked, but didn't; I get an error about
> >  "bad command format",
<snip>
> > the path to the file(s) includes more than one directory with SPACES in
> > them,
> > which I think is the problem, and I vaguely remember that there's a "trick"
> > to making directories with spaces work, but I don't rember what it IS.
> > 
> > Is there such a trick?  (& what is it if there is)
> > (in the code example above, I put the path to the file in front of myvar)
> 
> When there are spaces inside a file or directory name or path, it must
> be enclosed in double quotes. That's why in my example above I did NOT
> write
> myvar = "the old.txt the new.txt"
> 
> but
> }}}
<eucode>
> myvar = "\"the old.txt\" \"the new.txt\""
> </eucode>
{{{

> 
> This works fine here with EXW.EXE 2.5 on Windows 98, when "the old.txt"
> is a file as well as a directory. Now I tried a directory name that
> contains a path, e.g.
> }}}
<eucode>
> sequence myvar
> myvar = "\"c:\\temp\\the old\" \"c:\\temp\\the new\""
> system("rename " & myvar, 2)
> </eucode>
{{{

> 
> and, strange enough, I get the message:
> "Invalid parameter - c:\temp\the new".
> 
> But by virtue of the infinite wisdom of M$, when the _new_ name doesn't
> contain a path at all, everything seems to work fine:
> }}}
<eucode>
> sequence myvar
> myvar = "\"c:\\temp\\the old\" \"the new\""
> system("rename " & myvar, 2)
> </eucode>
{{{

> 
> As a general solution, I think something like the following can be used:
> }}}
<eucode>
> procedure rename (sequence oldNameWithPath, sequence newNameWithoutPath)
>    -- rename a file or directory (both names may contain spaces)
>    system(sprintf("rename \"%s\" \"%s\"", {oldNameWithPath,
>    newNameWithoutPath}), 2)
> end procedure
> </eucode>
{{{

> 
> Regards,
>    Juergen
> 

Thanks again Juergen, I'll give it a try.

Dan

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu