Page 1 of 1 1
Topic Options
#8822 - 2001-05-19 11:25 AM How do you redirect multiple quote marks?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
In the example below, how would you have %comspec% or writeprofile or similar command create a new file on a local or remote system.

code:
for /f "tokens=*" %%a in ('dir c:\*.mpg /s /b ' ''dir c:\*.asf /s /b ' 'dir c:\*.mov /s /b ') do (copy "%%a"  H:\MOVIES)

There are ' and "" and ( ) entries all over this command. The reason I ask is that many of these batch files need this type of structure and I don't know the proper KixTart syntax to echo it out to file or write it to file.
Also is it possible to somehow edit this batch file on the fly with KixTart?
If not easily, perhaps this could be a request for new feature in 2001 version to edit text files more easily.

NTDOC

[This message has been edited by NTDOC (edited 19 May 2001).]

Top
#8823 - 2001-05-22 12:05 AM Re: How do you redirect multiple quote marks?
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
NTDOC,

try replace the Quotation inside your Shell command
similar to the one you wrapped it with chr() code ...

for " use chr(34)
for ' use chr(39)

hth

Jochen

_________________________



Top
#8824 - 2001-05-21 01:35 PM Re: How do you redirect multiple quote marks?
Anonymous
Unregistered


Hi,

with follwing examples You can report each copy it was done. The first line will report in a file and the second on the STDOUT.

code:

@ECHO OFF
For /f "tokens=*" %%a in ('dir c:\Daten\*.kix /s /b ') do (echo "%%a" copied successfully >> C:\Temp\cp.log | Copy "%%a" C:\Temp)
For /f "tokens=*" %%a in ('dir c:\Daten\*.kix /s /b ') do (echo "%%a" copied successfully | Copy "%%a" C:\Temp)

I hope that is what´s You want.

Tom

Top
#8825 - 2001-05-23 12:25 AM Re: How do you redirect multiple quote marks?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
I think jpols may be more on to what I am looking for, but I am still not able to grasp the idea completely. Here is what I tried which DOES NOT work.

code:
IF Open( 1 , "%windir%\GETFILE.BAT" , 5 )  = 0
;$WL = WriteLine( 1 , "for /f "tokens=*" %%a in ('dir c:\*.mpg /s /b ' ''dir c:\*.asf /s /b ' 'dir c:\*.mov /s /b ') do (copy "%%a" H:\MOVIES)"+ Chr(13) + Chr(10))
;$WL = WriteLine( 1 , +char(39)for /f "tokens=*" %%a in ('dir c:\*.mpg /s /b ' ''dir c:\*.asf /s /b ' 'dir c:\*.mov /s /b ') do (copy "%%a" H:\MOVIES)+char(39)+ Chr(13) + Chr(10))
ELSE
BEEP
? "failed to open file, error code : [" + @ERROR + "]"
ENDIF

Thanks for the help

NTDOC

Top
#8826 - 2001-05-23 05:15 AM Re: How do you redirect multiple quote marks?
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
NTDOC, can you tell us (me) what that FOR... line does


ta, cj


Top
#8827 - 2001-05-23 09:02 AM Re: How do you redirect multiple quote marks?
Anonymous
Unregistered


OK - NTDOC,

I guess, You want write exactly this lines in a protocolfile, but many quotes are a problem. Test this lines:

code:

$WL = WriteLine( 1 , 'for /f "tokens=*" %%a in (' + "'" + 'dir c:\*.mpg /s /b ' + "' '" + 'dir c:\*.asf /s /b ' + "' '" + 'dir c:\*.mov /s /b ' + "'" + ') do (copy "%%a" H:\MOVIES)"' + Chr(13) + Chr(10))
$WL = WriteLine( 1 , 'for /f "tokens=*" %%a in (' + "'" + 'dir c:\*.mpg /s /b ' + "' '" + 'dir c:\*.asf /s /b ' + "' '" + 'dir c:\*.mov /s /b ' + "'" + ') do (copy "%%a" H:\MOVIES)"' + Chr(13) + Chr(10))


Tom

Top
#8828 - 2001-05-24 12:44 AM Re: How do you redirect multiple quote marks?
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
The simplest way to avoid headache inducing quote confusion is to assign them to a variable then use that.

I took one of your command lines:

code:
BREAK ON

$SQ="'"
$DQ='"'
$CRLF=char(13) + char(10)

$Command="for /f " + $DQ + "tokens=*" + $DQ + " %%a in (" + $SQ + "dir c:\*.mpg /s /b " + $SQ + " " + $SQ + $SQ + "dir c:\*.asf /s /b " + $SQ + " " + $SQ + "dir c:\*.mov /s /b " + $SQ + ") do (copy " + $DQ + "%%a" + $DQ + " H:\MOVIES)"+ $CRLF
$Command ?



You'd write it to a file, I just echoed it to a screen and got:
code:
for /f "tokens=*" %a in ('dir c:\*.mpg /s /b ' ''dir c:\*.asf /s /b ' 'dir c:\*.mov /s /b ') do (copy "%a"  H:\MOVIES)


------------------
Richard Howarth

Doh! Stupid line wrap.

[This message has been edited by rhowarth (edited 23 May 2001).]

Top
#8829 - 2001-05-23 09:08 PM Re: How do you redirect multiple quote marks?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Thank you everyone,

Richard wins the prize.. :-)

Jochen,
Thank you for your input and perhaps helping others to see what I was looking for.

cj,
This website shows the use of FOR as well as some of the other batch commands. http://www.labmice.net/articles/batchcmds.htm

Tom,
I was not able to get yours to work, but thank you for the input.

Richard,
You made it work, thank you much... Here is final code I got to work.

code:
BREAK ON
$SQ="'"
$DQ='"'
$CRLF="char(13) + char(10)"
$Command="for /f " + $DQ + "tokens=*" + $DQ + " %%a in (" + $SQ + "dir c:\*.mpg /s /b " + $SQ + " " + $SQ + $SQ + "dir c:\*.asf /s /b " + $SQ + " " + $SQ + "dir c:\*.mov /s /b " + $SQ + ") do (copy " + $DQ + "%%a" + $DQ + " H:\MOVIES)"
IF Open( 1 , "%windir%\GETFILE.BAT" , 5 ) = 0
WriteLine( 1 , "$Command")
ELSE
? "failed to open file, error code : [" + @ERROR + "]"
ENDIF

For the clarification of others who may want to use your code sample, I think you had a typo

code:

Your line was missing " "
$CRLF=char(13) + char(10)
New line
$CRLF="char(13) + char(10)"

Thanks again to everyone...

NTDOC

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 293 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.053 seconds in which 0.022 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org