I believe this is called DOS batch scripting. I found this example via
Google. It contains much of the same commands, such as tokens, and delims,
as what I need to translate. How can I translate this code into VBS ?

SET SIZE1=0
SET SIZE=0
FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO %%~zi >>D:\size.txt
FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO d:\%%i + >>D:\list.txt
FOR /F "tokens=*" %%i in ('type "d:\list.txt"') DO SET LIST=%%i

FOR /F "tokens=*" %%i in ('type "d:\size.txt"') DO SET /A SIZE1=%%i+%SIZE1%

Re: Translate by Pegasus

Pegasus
Sun Mar 02 14:05:05 CST 2008


"Kyle" <Kyle@discussions.microsoft.com> wrote in message
news:404F42AF-DC5F-4457-A19E-EECB41E505E6@microsoft.com...
>I believe this is called DOS batch scripting. I found this example via
> Google. It contains much of the same commands, such as tokens, and
> delims,
> as what I need to translate. How can I translate this code into VBS ?
>
> SET SIZE1=0
> SET SIZE=0
> FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO %%~zi >>D:\size.txt
> FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO d:\%%i + >>D:\list.txt
> FOR /F "tokens=*" %%i in ('type "d:\list.txt"') DO SET LIST=%%i
>
> FOR /F "tokens=*" %%i in ('type "d:\size.txt"') DO SET /A
> SIZE1=%%i+%SIZE1%
>

"DOS" could never do this sort of thing but the Command
Prompt under Windows can. Here is an explanation of each
command. All of them have their equivalents in the VB Script
"File System Object".

FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO %%~zi >>D:\size.txt
Write the size of each *.m2v file to D:\ to D:\size.txt.

FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO d:\%%i + >>D:\list.txt
Write the name of each *.m2v file to D:\ to D:\list.txt.

FOR /F "tokens=*" %%i in ('type "d:\list.txt"') DO SET LIST=%%i
Set the LIST environmental variable to the last line found in "list.txt".

FOR /F "tokens=*" %%i in ('type "d:\size.txt"') DO SET /A SIZE1=%%i+%SIZE1%
Set the SIZE1 environmental variable to the sum of all file sizes.

The commands don't make a great deal of sense. In its current
form the batch file is incomplete and some of its tasks could be
solved in more elegant ways.



Re: Translate by Paul

Paul
Sun Mar 02 15:19:34 CST 2008


"Kyle" <Kyle@discussions.microsoft.com> wrote in message
news:404F42AF-DC5F-4457-A19E-EECB41E505E6@microsoft.com...
>I believe this is called DOS batch scripting. I found this example
>via
> Google. It contains much of the same commands, such as tokens, and
> delims,
> as what I need to translate. How can I translate this code into VBS
> ?
>
> SET SIZE1=0
> SET SIZE=0
> FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO %%~zi >>D:\size.txt
> FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO d:\%%i + >>D:\list.txt
> FOR /F "tokens=*" %%i in ('type "d:\list.txt"') DO SET LIST=%%i
>
> FOR /F "tokens=*" %%i in ('type "d:\size.txt"') DO SET /A
> SIZE1=%%i+%SIZE1%

Hi, Kyle
Pegasus is one of the best resources for finding out what a batch
command sequence does. WXP has one good resource too. Look for file
ntcmds.chm. It has an Command Line A-Z listing. Look in the Batch
files entry. There are nuggets of information hidden throughout the
various batch topics, such as when to use % vs %%. I find it
difficult to interpret other people's batch files because they don't
write the script with human readability in mind. For example, I find
it difficult to parse SIZE1=%%i+%SIZE1%, and I don't understand the
syntax well enough to know where spaces can be inserted for
readability.

-Paul Randall



Re: Translate by Pegasus

Pegasus
Sun Mar 02 15:33:44 CST 2008


"Paul Randall" <paulr901@cableone.net> wrote in message
news:uFVkRsKfIHA.5620@TK2MSFTNGP04.phx.gbl...
>
> "Kyle" <Kyle@discussions.microsoft.com> wrote in message
> news:404F42AF-DC5F-4457-A19E-EECB41E505E6@microsoft.com...
>>I believe this is called DOS batch scripting. I found this example via
>> Google. It contains much of the same commands, such as tokens, and
>> delims,
>> as what I need to translate. How can I translate this code into VBS ?
>>
>> SET SIZE1=0
>> SET SIZE=0
>> FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO %%~zi >>D:\size.txt
>> FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO d:\%%i + >>D:\list.txt
>> FOR /F "tokens=*" %%i in ('type "d:\list.txt"') DO SET LIST=%%i
>>
>> FOR /F "tokens=*" %%i in ('type "d:\size.txt"') DO SET /A
>> SIZE1=%%i+%SIZE1%
>
> Hi, Kyle
> Pegasus is one of the best resources for finding out what a batch command
> sequence does.

Thanks for the compliment but I strongly disagree. If the OP
wants to talk to the top-notch experts in batch file programming
then alt.msdos.batch.nt is the newsgroup to check.



Re: Translate by Todd

Todd
Sun Mar 02 23:13:13 CST 2008

Pegasus (MVP) wrote:
> "Kyle" <Kyle@discussions.microsoft.com> wrote in message
> news:404F42AF-DC5F-4457-A19E-EECB41E505E6@microsoft.com...
> >I believe this is called DOS batch scripting. I found this example via
> > Google. It contains much of the same commands, such as tokens, and
> > delims,
> > as what I need to translate. How can I translate this code into VBS ?
> >
> > SET SIZE1=0
> > SET SIZE=0
> > FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO %%~zi >>D:\size.txt
> > FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO d:\%%i + >>D:\list.txt
> > FOR /F "tokens=*" %%i in ('type "d:\list.txt"') DO SET LIST=%%i
> >
> > FOR /F "tokens=*" %%i in ('type "d:\size.txt"') DO SET /A
> > SIZE1=%%i+%SIZE1%
> >
>
> "DOS" could never do this sort of thing but the Command
> Prompt under Windows can. Here is an explanation of each
> command. All of them have their equivalents in the VB Script
> "File System Object".
>
> FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO %%~zi >>D:\size.txt
> Write the size of each *.m2v file to D:\ to D:\size.txt.
>
> FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO d:\%%i + >>D:\list.txt
> Write the name of each *.m2v file to D:\ to D:\list.txt.

First of all, the two for commands contain unbalanced double quotes. As I
recall, the NT line (what this code is for) balks at unbalanced quotes.
Secondly, the /F switch was not used so even if dbl-quotes were balanced,
all the FOR command would do is pass the quoted string "DIR /B D:\*.m2v" as
plain text, not a list of *.m2v files as expected.

FOR %%i in (D:\*.m2v) DO ECHO %%~zi >>D:\size.txt
FOR %%i in (D:\*.m2v) DO ECHO %%~fi >>D:\list.txt

>
> FOR /F "tokens=*" %%i in ('type "d:\list.txt"') DO SET LIST=%%i
> Set the LIST environmental variable to the last line found in "list.txt".
>
> FOR /F "tokens=*" %%i in ('type "d:\size.txt"') DO SET /A
SIZE1=%%i+%SIZE1%
> Set the SIZE1 environmental variable to the sum of all file sizes.
>
> The commands don't make a great deal of sense. In its current
> form the batch file is incomplete and some of its tasks could be
> solved in more elegant ways.

I agree. Basically, one can not translate non-working code reliably,
however, the following should help OP along. HTH

path = "D:\"
ext = "m2v"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(path)
Set fc = f.Files
For Each f1 in fc
If Ucase(fso.GetExtensionName(f1)) = Ucase(ext) Then
list = list & f1.Name & vbcrlf
size = size + f1.Size
End If
Next
Wscript.Echo list, " ", size, "bytes"

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)


Re: Translate by kbass

kbass
Mon Mar 03 09:39:33 CST 2008

On Mar 3, 12:13 am, "Todd Vargo" <tlva...@sbcglobal.netz> wrote:
> Pegasus (MVP) wrote:
> > "Kyle" <K...@discussions.microsoft.com> wrote in message
> >news:404F42AF-DC5F-4457-A19E-EECB41E505E6@microsoft.com...
> > >I believe this is called DOS batch scripting. I found this example via
> > > Google. It contains much of the same commands, such as tokens, and
> > > delims,
> > > as what I need to translate. How can I translate this code into VBS ?
>
> > > SET SIZE1=0
> > > SET SIZE=0
> > > FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO %%~zi >>D:\size.txt
> > > FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO d:\%%i + >>D:\list.txt
> > > FOR /F "tokens=*" %%i in ('type "d:\list.txt"') DO SET LIST=%%i
>
> > > FOR /F "tokens=*" %%i in ('type "d:\size.txt"') DO SET /A
> > > SIZE1=%%i+%SIZE1%
>
> > "DOS" could never do this sort of thing but the Command
> > Prompt under Windows can. Here is an explanation of each
> > command. All of them have their equivalents in the VB Script
> > "File System Object".
>
> > FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO %%~zi >>D:\size.txt
> > Write the size of each *.m2v file to D:\ to D:\size.txt.
>
> > FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO d:\%%i + >>D:\list.txt
> > Write the name of each *.m2v file to D:\ to D:\list.txt.
>
> First of all, the two for commands contain unbalanced double quotes. As I
> recall, the NT line (what this code is for) balks at unbalanced quotes.
> Secondly, the /F switch was not used so even if dbl-quotes were balanced,
> all the FOR command would do is pass the quoted string "DIR /B D:\*.m2v" as
> plain text, not a list of *.m2v files as expected.
>
> FOR %%i in (D:\*.m2v) DO ECHO %%~zi >>D:\size.txt
> FOR %%i in (D:\*.m2v) DO ECHO %%~fi >>D:\list.txt
>
>
>
>
>
> > FOR /F "tokens=*" %%i in ('type "d:\list.txt"') DO SET LIST=%%i
> > Set the LIST environmental variable to the last line found in "list.txt".
>
> > FOR /F "tokens=*" %%i in ('type "d:\size.txt"') DO SET /A
> SIZE1=%%i+%SIZE1%
> > Set the SIZE1 environmental variable to the sum of all file sizes.
>
> > The commands don't make a great deal of sense. In its current
> > form the batch file is incomplete and some of its tasks could be
> > solved in more elegant ways.
>
> I agree. Basically, one can not translate non-working code reliably,
> however, the following should help OP along. HTH
>
> path = "D:\"
> ext = "m2v"
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set f = fso.GetFolder(path)
> Set fc = f.Files
> For Each f1 in fc
> If Ucase(fso.GetExtensionName(f1)) = Ucase(ext) Then
> list = list & f1.Name & vbcrlf
> size = size + f1.Size
> End If
> Next
> Wscript.Echo list, " ", size, "bytes"
>
> --
> Todd Vargo
> (Post questions to group only. Remove "z" to email personal messages)

Thanks all. I want to understand this logic, but I have a large task
at hand and little time to complete it. It would be easiest for me,
if I could find some sort of app/program to translate this code into
VBS.

What does .."OP"....stand for..in Pegasus' post ? Thanks for the link
to that group Pegasus.

Re: Translate by Pegasus

Pegasus
Mon Mar 03 09:58:37 CST 2008


"kbass" <kyle.bassman@gmail.com> wrote in message
news:85ecddd8-17bb-4e74-8e3b-dec0f50276c7@u10g2000prn.googlegroups.com...
> On Mar 3, 12:13 am, "Todd Vargo" <tlva...@sbcglobal.netz> wrote:
>> Pegasus (MVP) wrote:
>> > "Kyle" <K...@discussions.microsoft.com> wrote in message
>> >news:404F42AF-DC5F-4457-A19E-EECB41E505E6@microsoft.com...
>> > >I believe this is called DOS batch scripting. I found this example
>> > >via
>> > > Google. It contains much of the same commands, such as tokens, and
>> > > delims,
>> > > as what I need to translate. How can I translate this code into VBS ?
>>
>> > > SET SIZE1=0
>> > > SET SIZE=0
>> > > FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO %%~zi >>D:\size.txt
>> > > FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO d:\%%i + >>D:\list.txt
>> > > FOR /F "tokens=*" %%i in ('type "d:\list.txt"') DO SET LIST=%%i
>>
>> > > FOR /F "tokens=*" %%i in ('type "d:\size.txt"') DO SET /A
>> > > SIZE1=%%i+%SIZE1%
>>
>> > "DOS" could never do this sort of thing but the Command
>> > Prompt under Windows can. Here is an explanation of each
>> > command. All of them have their equivalents in the VB Script
>> > "File System Object".
>>
>> > FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO %%~zi >>D:\size.txt
>> > Write the size of each *.m2v file to D:\ to D:\size.txt.
>>
>> > FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO d:\%%i + >>D:\list.txt
>> > Write the name of each *.m2v file to D:\ to D:\list.txt.
>>
>> First of all, the two for commands contain unbalanced double quotes. As I
>> recall, the NT line (what this code is for) balks at unbalanced quotes.
>> Secondly, the /F switch was not used so even if dbl-quotes were balanced,
>> all the FOR command would do is pass the quoted string "DIR /B D:\*.m2v"
>> as
>> plain text, not a list of *.m2v files as expected.
>>
>> FOR %%i in (D:\*.m2v) DO ECHO %%~zi >>D:\size.txt
>> FOR %%i in (D:\*.m2v) DO ECHO %%~fi >>D:\list.txt
>>
>>
>>
>>
>>
>> > FOR /F "tokens=*" %%i in ('type "d:\list.txt"') DO SET LIST=%%i
>> > Set the LIST environmental variable to the last line found in
>> > "list.txt".
>>
>> > FOR /F "tokens=*" %%i in ('type "d:\size.txt"') DO SET /A
>> SIZE1=%%i+%SIZE1%
>> > Set the SIZE1 environmental variable to the sum of all file sizes.
>>
>> > The commands don't make a great deal of sense. In its current
>> > form the batch file is incomplete and some of its tasks could be
>> > solved in more elegant ways.
>>
>> I agree. Basically, one can not translate non-working code reliably,
>> however, the following should help OP along. HTH
>>
>> path = "D:\"
>> ext = "m2v"
>> Set fso = CreateObject("Scripting.FileSystemObject")
>> Set f = fso.GetFolder(path)
>> Set fc = f.Files
>> For Each f1 in fc
>> If Ucase(fso.GetExtensionName(f1)) = Ucase(ext) Then
>> list = list & f1.Name & vbcrlf
>> size = size + f1.Size
>> End If
>> Next
>> Wscript.Echo list, " ", size, "bytes"
>>
>> --
>> Todd Vargo
>> (Post questions to group only. Remove "z" to email personal messages)
>
> Thanks all. I want to understand this logic, but I have a large task
> at hand and little time to complete it. It would be easiest for me,
> if I could find some sort of app/program to translate this code into
> VBS.
>
> What does .."OP"....stand for..in Pegasus' post ? Thanks for the link
> to that group Pegasus.

"OP" is the commonly used abbreviation for "Original Poster",
i.e. yourself.

I don't think there is any tool to translate batch code into VB
Script. The two languages are radically different.

If you have a large task at hand then I see these options for
you:
a) Learn the language. This will obviously take time.
b) Pay someone to do the job for you.
c) See if someone in this group is willing to do the job free
of charge, out of the goodness of his heart.

If this was my show then I would go for option b) in the short
term and option a) in the long term. Scripting is an expert skill
and people who have acquired this skill deserve to be
compensated, same as in any other professional field.



Re: Translate by Pegasus

Pegasus
Mon Mar 03 10:18:05 CST 2008


"kbass" <kyle.bassman@gmail.com> wrote in message
news:85ecddd8-17bb-4e74-8e3b-dec0f50276c7@u10g2000prn.googlegroups.com...
> On Mar 3, 12:13 am, "Todd Vargo" <tlva...@sbcglobal.netz> wrote:
>> Pegasus (MVP) wrote:
>> > "Kyle" <K...@discussions.microsoft.com> wrote in message
>> >news:404F42AF-DC5F-4457-A19E-EECB41E505E6@microsoft.com...
>> > >I believe this is called DOS batch scripting. I found this example
>> > >via
>> > > Google. It contains much of the same commands, such as tokens, and
>> > > delims,
>> > > as what I need to translate. How can I translate this code into VBS ?
>>
>> > > SET SIZE1=0
>> > > SET SIZE=0
>> > > FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO %%~zi >>D:\size.txt
>> > > FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO d:\%%i + >>D:\list.txt
>> > > FOR /F "tokens=*" %%i in ('type "d:\list.txt"') DO SET LIST=%%i
>>
>> > > FOR /F "tokens=*" %%i in ('type "d:\size.txt"') DO SET /A
>> > > SIZE1=%%i+%SIZE1%
>>
>> > "DOS" could never do this sort of thing but the Command
>> > Prompt under Windows can. Here is an explanation of each
>> > command. All of them have their equivalents in the VB Script
>> > "File System Object".
>>
>> > FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO %%~zi >>D:\size.txt
>> > Write the size of each *.m2v file to D:\ to D:\size.txt.
>>
>> > FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO d:\%%i + >>D:\list.txt
>> > Write the name of each *.m2v file to D:\ to D:\list.txt.
>>
>> First of all, the two for commands contain unbalanced double quotes. As I
>> recall, the NT line (what this code is for) balks at unbalanced quotes.
>> Secondly, the /F switch was not used so even if dbl-quotes were balanced,
>> all the FOR command would do is pass the quoted string "DIR /B D:\*.m2v"
>> as
>> plain text, not a list of *.m2v files as expected.
>>
>> FOR %%i in (D:\*.m2v) DO ECHO %%~zi >>D:\size.txt
>> FOR %%i in (D:\*.m2v) DO ECHO %%~fi >>D:\list.txt
>>
>>
>>
>>
>>
>> > FOR /F "tokens=*" %%i in ('type "d:\list.txt"') DO SET LIST=%%i
>> > Set the LIST environmental variable to the last line found in
>> > "list.txt".
>>
>> > FOR /F "tokens=*" %%i in ('type "d:\size.txt"') DO SET /A
>> SIZE1=%%i+%SIZE1%
>> > Set the SIZE1 environmental variable to the sum of all file sizes.
>>
>> > The commands don't make a great deal of sense. In its current
>> > form the batch file is incomplete and some of its tasks could be
>> > solved in more elegant ways.
>>
>> I agree. Basically, one can not translate non-working code reliably,
>> however, the following should help OP along. HTH
>>
>> path = "D:\"
>> ext = "m2v"
>> Set fso = CreateObject("Scripting.FileSystemObject")
>> Set f = fso.GetFolder(path)
>> Set fc = f.Files
>> For Each f1 in fc
>> If Ucase(fso.GetExtensionName(f1)) = Ucase(ext) Then
>> list = list & f1.Name & vbcrlf
>> size = size + f1.Size
>> End If
>> Next
>> Wscript.Echo list, " ", size, "bytes"
>>
>> --
>> Todd Vargo
>> (Post questions to group only. Remove "z" to email personal messages)
>
> Thanks all. I want to understand this logic, but I have a large task
> at hand and little time to complete it. It would be easiest for me,
> if I could find some sort of app/program to translate this code into
> VBS.
>
> What does .."OP"....stand for..in Pegasus' post ? Thanks for the link
> to that group Pegasus.

By the way, I note that you posted the same question in a Windows
Batch group. There is nothing wrong with posting the same question
in several groups, provided you do it correctly, i.e. by "cross-posting".
If you "multi-post" (as you did) then your popularity rating will drop
very quickly because muli-posting result in duplication of effort and
therefore causes waste of time.

See here for the details:
http://www.blakjak.demon.co.uk/mul_crss.htm



Re: Translate by kbass

kbass
Mon Mar 03 10:41:25 CST 2008

On Mar 3, 11:18 am, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
> "kbass" <kyle.bass...@gmail.com> wrote in message
>
> news:85ecddd8-17bb-4e74-8e3b-dec0f50276c7@u10g2000prn.googlegroups.com...
>
>
>
> > On Mar 3, 12:13 am, "Todd Vargo" <tlva...@sbcglobal.netz> wrote:
> >> Pegasus (MVP) wrote:
> >> > "Kyle" <K...@discussions.microsoft.com> wrote in message
> >> >news:404F42AF-DC5F-4457-A19E-EECB41E505E6@microsoft.com...
> >> > >I believe this is called DOS batch scripting. I found this example
> >> > >via
> >> > > Google. It contains much of the same commands, such as tokens, and
> >> > > delims,
> >> > > as what I need to translate. How can I translate this code into VBS ?
>
> >> > > SET SIZE1=0
> >> > > SET SIZE=0
> >> > > FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO %%~zi >>D:\size.txt
> >> > > FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO d:\%%i + >>D:\list.txt
> >> > > FOR /F "tokens=*" %%i in ('type "d:\list.txt"') DO SET LIST=%%i
>
> >> > > FOR /F "tokens=*" %%i in ('type "d:\size.txt"') DO SET /A
> >> > > SIZE1=%%i+%SIZE1%
>
> >> > "DOS" could never do this sort of thing but the Command
> >> > Prompt under Windows can. Here is an explanation of each
> >> > command. All of them have their equivalents in the VB Script
> >> > "File System Object".
>
> >> > FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO %%~zi >>D:\size.txt
> >> > Write the size of each *.m2v file to D:\ to D:\size.txt.
>
> >> > FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO d:\%%i + >>D:\list.txt
> >> > Write the name of each *.m2v file to D:\ to D:\list.txt.
>
> >> First of all, the two for commands contain unbalanced double quotes. As I
> >> recall, the NT line (what this code is for) balks at unbalanced quotes.
> >> Secondly, the /F switch was not used so even if dbl-quotes were balanced,
> >> all the FOR command would do is pass the quoted string "DIR /B D:\*.m2v"
> >> as
> >> plain text, not a list of *.m2v files as expected.
>
> >> FOR %%i in (D:\*.m2v) DO ECHO %%~zi >>D:\size.txt
> >> FOR %%i in (D:\*.m2v) DO ECHO %%~fi >>D:\list.txt
>
> >> > FOR /F "tokens=*" %%i in ('type "d:\list.txt"') DO SET LIST=%%i
> >> > Set the LIST environmental variable to the last line found in
> >> > "list.txt".
>
> >> > FOR /F "tokens=*" %%i in ('type "d:\size.txt"') DO SET /A
> >> SIZE1=%%i+%SIZE1%
> >> > Set the SIZE1 environmental variable to the sum of all file sizes.
>
> >> > The commands don't make a great deal of sense. In its current
> >> > form the batch file is incomplete and some of its tasks could be
> >> > solved in more elegant ways.
>
> >> I agree. Basically, one can not translate non-working code reliably,
> >> however, the following should help OP along. HTH
>
> >> path = "D:\"
> >> ext = "m2v"
> >> Set fso = CreateObject("Scripting.FileSystemObject")
> >> Set f = fso.GetFolder(path)
> >> Set fc = f.Files
> >> For Each f1 in fc
> >> If Ucase(fso.GetExtensionName(f1)) = Ucase(ext) Then
> >> list = list & f1.Name & vbcrlf
> >> size = size + f1.Size
> >> End If
> >> Next
> >> Wscript.Echo list, " ", size, "bytes"
>
> >> --
> >> Todd Vargo
> >> (Post questions to group only. Remove "z" to email personal messages)
>
> > Thanks all. I want to understand this logic, but I have a large task
> > at hand and little time to complete it. It would be easiest for me,
> > if I could find some sort of app/program to translate this code into
> > VBS.
>
> > What does .."OP"....stand for..in Pegasus' post ? Thanks for the link
> > to that group Pegasus.
>
> By the way, I note that you posted the same question in a Windows
> Batch group. There is nothing wrong with posting the same question
> in several groups, provided you do it correctly, i.e. by "cross-posting".
> If you "multi-post" (as you did) then your popularity rating will drop
> very quickly because muli-posting result in duplication of effort and
> therefore causes waste of time.
>
> See here for the details:http://www.blakjak.demon.co.uk/mul_crss.htm

AH. I see what happened now. My apologies. I was not sure where I
should be posting. I will keep this question in the other forum you
gave me. Again, my apologies.

Re: Translate by kbass

kbass
Mon Mar 03 10:46:43 CST 2008

On Mar 3, 10:58 am, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
> "kbass" <kyle.bass...@gmail.com> wrote in message
>
> news:85ecddd8-17bb-4e74-8e3b-dec0f50276c7@u10g2000prn.googlegroups.com...
>
>
>
> > On Mar 3, 12:13 am, "Todd Vargo" <tlva...@sbcglobal.netz> wrote:
> >> Pegasus (MVP) wrote:
> >> > "Kyle" <K...@discussions.microsoft.com> wrote in message
> >> >news:404F42AF-DC5F-4457-A19E-EECB41E505E6@microsoft.com...
> >> > >I believe this is called DOS batch scripting. I found this example
> >> > >via
> >> > > Google. It contains much of the same commands, such as tokens, and
> >> > > delims,
> >> > > as what I need to translate. How can I translate this code into VBS ?
>
> >> > > SET SIZE1=0
> >> > > SET SIZE=0
> >> > > FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO %%~zi >>D:\size.txt
> >> > > FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO d:\%%i + >>D:\list.txt
> >> > > FOR /F "tokens=*" %%i in ('type "d:\list.txt"') DO SET LIST=%%i
>
> >> > > FOR /F "tokens=*" %%i in ('type "d:\size.txt"') DO SET /A
> >> > > SIZE1=%%i+%SIZE1%
>
> >> > "DOS" could never do this sort of thing but the Command
> >> > Prompt under Windows can. Here is an explanation of each
> >> > command. All of them have their equivalents in the VB Script
> >> > "File System Object".
>
> >> > FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO %%~zi >>D:\size.txt
> >> > Write the size of each *.m2v file to D:\ to D:\size.txt.
>
> >> > FOR %%i in ("DIR /B "D:\*.m2v") DO ECHO d:\%%i + >>D:\list.txt
> >> > Write the name of each *.m2v file to D:\ to D:\list.txt.
>
> >> First of all, the two for commands contain unbalanced double quotes. As I
> >> recall, the NT line (what this code is for) balks at unbalanced quotes.
> >> Secondly, the /F switch was not used so even if dbl-quotes were balanced,
> >> all the FOR command would do is pass the quoted string "DIR /B D:\*.m2v"
> >> as
> >> plain text, not a list of *.m2v files as expected.
>
> >> FOR %%i in (D:\*.m2v) DO ECHO %%~zi >>D:\size.txt
> >> FOR %%i in (D:\*.m2v) DO ECHO %%~fi >>D:\list.txt
>
> >> > FOR /F "tokens=*" %%i in ('type "d:\list.txt"') DO SET LIST=%%i
> >> > Set the LIST environmental variable to the last line found in
> >> > "list.txt".
>
> >> > FOR /F "tokens=*" %%i in ('type "d:\size.txt"') DO SET /A
> >> SIZE1=%%i+%SIZE1%
> >> > Set the SIZE1 environmental variable to the sum of all file sizes.
>
> >> > The commands don't make a great deal of sense. In its current
> >> > form the batch file is incomplete and some of its tasks could be
> >> > solved in more elegant ways.
>
> >> I agree. Basically, one can not translate non-working code reliably,
> >> however, the following should help OP along. HTH
>
> >> path = "D:\"
> >> ext = "m2v"
> >> Set fso = CreateObject("Scripting.FileSystemObject")
> >> Set f = fso.GetFolder(path)
> >> Set fc = f.Files
> >> For Each f1 in fc
> >> If Ucase(fso.GetExtensionName(f1)) = Ucase(ext) Then
> >> list = list & f1.Name & vbcrlf
> >> size = size + f1.Size
> >> End If
> >> Next
> >> Wscript.Echo list, " ", size, "bytes"
>
> >> --
> >> Todd Vargo
> >> (Post questions to group only. Remove "z" to email personal messages)
>
> > Thanks all. I want to understand this logic, but I have a large task
> > at hand and little time to complete it. It would be easiest for me,
> > if I could find some sort of app/program to translate this code into
> > VBS.
>
> > What does .."OP"....stand for..in Pegasus' post ? Thanks for the link
> > to that group Pegasus.
>
> "OP" is the commonly used abbreviation for "Original Poster",
> i.e. yourself.
>
> I don't think there is any tool to translate batch code into VB
> Script. The two languages are radically different.
>
> If you have a large task at hand then I see these options for
> you:
> a) Learn the language. This will obviously take time.
> b) Pay someone to do the job for you.
> c) See if someone in this group is willing to do the job free
> of charge, out of the goodness of his heart.
>
> If this was my show then I would go for option b) in the short
> term and option a) in the long term. Scripting is an expert skill
> and people who have acquired this skill deserve to be
> compensated, same as in any other professional field.

Thanks. I want to learn it, but time is of the essence. Your replies
are much appreciated.