Home > Archive > Tcl > April 2005 > Spaces in filename
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Spaces in filename
|
|
| ryhahm@gmail.com 2005-04-18, 3:57 am |
| I am trying to use tcl to create a dynamic like bat file so that I can
do backups of the "My Documents" folder. So I have the following line
in my tcl script.
puts $bkcmdid "zip -r \\\\intrepid\\samba\\hahmpc9bakup\\ryh-$tname.zip
c:\\Documents and Settings\\mydir\\My Documents\\*.*"
This creates the following line in the batch file.
zip -r \\intrepid\samba\hahmpc9bakup\ryh-Sunday_17Apr2005.zip
c:\Documents and Settings\mydir\My Documents\*.*
But the Windows batch language requires double quotes (") around the My
Documents path.
I am unable to figure out to create the double quotes I need. I tried
looking in the TCL book I have and scouring the internet, but I am able
to find a solution for this.
I apologize if this is a newbie like question, but I am a newbie to
tcl.
| |
| lvirden@gmail.com 2005-04-18, 3:59 pm |
|
According to maxima2k <rh10023@hotmail.com>:
:I am unable to figure out to create the double quotes I need.
Try something like this:
$ tclsh
puts [format "zip -r \"%s\" \"%s\"" [file join intrepid samba $tname.zip] [file join c: "Documents and Settings" mydir "My Documents" *.*] ]
where you put within the file join command the pieces of your filename - without
all those backslashes. Put the pieces with spaces in quotes. And use those
\" to insert the required quotes in the resulting string.
--
<URL: http://wiki.tcl.tk/ > MP3 ID tag repair < http://www.fixtunes.com/?C=17038 >
Even if explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.
<URL: mailto:lvirden@gmail.com > <URL: http://www.purl.org/NET/lvirden/ >
| |
| Schelte Bron 2005-04-18, 3:59 pm |
| On 04/18/05 12:35, lvirden@gmail.com wrote:
> According to maxima2k <rh10023@hotmail.com>:
> :I am unable to figure out to create the double quotes I need.
> Try something like this:
>
> $ tclsh
> puts [format "zip -r \"%s\" \"%s\"" [file join intrepid samba $tname.zip] [file join c: "Documents and Settings" mydir "My Documents" *.*] ]
>
I'm not on Windows but I think you should do something closer to this:
puts [format {zip -r "\\%s\%s" "%s"} intrepid \
[file nativename [file join samba hahmpc9bakup _ryh-$tname.zip]] \
[file nativename [file join "c:/Documents and Settings" mydir \
"My Documents" *.*]]]
Schelte
--
set Reply-To [string map {nospam schelte} $header(From)]
| |
| lvirden@gmail.com 2005-04-19, 3:59 am |
|
According to Schelte Bron <nospam@wanadoo.nl>:
:On 04/18/05 12:35, lvirden@gmail.com wrote:
:> According to maxima2k <rh10023@hotmail.com>:
:> :I am unable to figure out to create the double quotes I need.
:> Try something like this:
:>
:> $ tclsh
:> puts [format "zip -r \"%s\" \"%s\"" [file join intrepid samba $tname.zip] [file join c:
:"Documents and Settings" mydir "My Documents" *.*] ]
:>
:I'm not on Windows but I think you should do something closer to this:
:puts [format {zip -r "\\%s\%s" "%s"} intrepid \
: [file nativename [file join samba hahmpc9bakup _ryh-$tname.zip]] \
: [file nativename [file join "c:/Documents and Settings" mydir \
: "My Documents" *.*]]]
Hmm - why do you hard code the backslashes for intrepid? Is it something
special? If so, then perhaps the window users know what special thing should be
done to avoid hard coding those backslashes - the whole purpose of those
special file minor commands was so that the developer never had to hard code
slashes or backslashes, I thought.
--
<URL: http://wiki.tcl.tk/ > MP3 ID tag repair < http://www.fixtunes.com/?C=17038 >
Even if explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.
<URL: mailto:lvirden@gmail.com > <URL: http://www.purl.org/NET/lvirden/ >
| |
| Schelte Bron 2005-04-19, 8:58 pm |
| On 04/18/05 19:00, lvirden@gmail.com wrote:
> According to Schelte Bron <nospam@wanadoo.nl>:
> :On 04/18/05 12:35, lvirden@gmail.com wrote:
> :> According to maxima2k <rh10023@hotmail.com>:
> :> :I am unable to figure out to create the double quotes I need.
> :> Try something like this:
> :>
> :> $ tclsh
> :> puts [format "zip -r \"%s\" \"%s\"" [file join intrepid samba $tname.zip] [file join c:
> :"Documents and Settings" mydir "My Documents" *.*] ]
> :>
> :I'm not on Windows but I think you should do something closer to this:
> :puts [format {zip -r "\\%s\%s" "%s"} intrepid \
> : [file nativename [file join samba hahmpc9bakup _ryh-$tname.zip]] \
> : [file nativename [file join "c:/Documents and Settings" mydir \
> : "My Documents" *.*]]]
>
>
> Hmm - why do you hard code the backslashes for intrepid? Is it something
> special? If so, then perhaps the window users know what special thing should be
> done to avoid hard coding those backslashes - the whole purpose of those
> special file minor commands was so that the developer never had to hard code
> slashes or backslashes, I thought.
Intrepid appears to be a machine name, not part of the path. I assume
file join would join them togetether into a single backslash, giving
something with a completely different meaning.
The file minor commands are only for local files, I think. Like I said,
I'm not on Windows so I can't really check.
Schelte.
--
set Reply-To [string map {nospam schelte} $header(From)]
|
|
|
|
|