Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Spaces in filename
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.


Report this thread to moderator Post Follow-up to this message
Old Post
ryhahm@gmail.com
04-18-05 08:57 AM


Re: Spaces in filename
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] [f
ile join c: "Documents and Settings" mydir "My Documents" *.*] ]


where you put within the file join command the pieces of your filename - wit
hout
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[/<...rg/NET/lvirden/ >

Report this thread to moderator Post Follow-up to this message
Old Post
lvirden@gmail.com
04-18-05 08:59 PM


Re: Spaces in filename
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)]

Report this thread to moderator Post Follow-up to this message
Old Post
Schelte Bron
04-18-05 08:59 PM


Re: Spaces in filename
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 shoul
d 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[/<...rg/NET/lvirden/ >

Report this thread to moderator Post Follow-up to this message
Old Post
lvirden@gmail.com
04-19-05 08:59 AM


Re: Spaces in filename
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.zi
p] [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 sho
uld 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 co
de
> 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)]

Report this thread to moderator Post Follow-up to this message
Old Post
Schelte Bron
04-20-05 01:58 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Tcl archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:20 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.