Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Command Prompt (CMD); Two issues about DIR command  (Read 8195 times)

0 Members and 1 Guest are viewing this topic.

Salmon Trout

  • Guest
Re: Command Prompt (CMD); Two issues about DIR command
« Reply #15 on: November 27, 2009, 12:27:42 AM »
thats the problem, you can't use for loops in the command prompt without a script.

That is not so; at the prompt you just use one % sign in the loop variables (instead of two)

Code: [Select]

S:\Test>for /f "tokens=1,2,3,4,5 delims=\" %a in ('dir /ad /s /b') do @echo %a\%b\%c\%d\%e

S:\Test\Batch\Older\custom-path
S:\Test\Other\Auto-it\
S:\Test\Other\Basic\
S:\Test\Other\beep\
S:\Test\Other\cURL\
S:\Test\Other\FTP\
S:\Test\Other\FUS-Repair\
S:\Test\Other\getmail\
S:\Test\Other\ghacker\
S:\Test\Other\hta\
S:\Test\Other\kix\
S:\Test\Other\Mirakagi\
S:\Test\Other\NATW\
S:\Test\Other\PopClient\
S:\Test\Other\Portable-Ubuntu\
S:\Test\Other\Python\
S:\Test\Other\reg\
S:\Test\Other\Ruby\
S:\Test\Other\textview\
S:\Test\Other\UnxUtils\
S:\Test\Other\virtual disk\
S:\Test\Other\wget_GUI\
S:\Test\Other\winmsg\
S:\Test\Other\winWget\
S:\Test\Other\wmv-avi\
S:\Test\Other\Zerodir\
S:\Test\Other\Auto-it\Auto-it3
S:\Test\Other\Auto-it\Checkbox
S:\Test\Other\Auto-it\MsgBox
S:\Test\Other\Auto-it\Auto-it3
S:\Test\Other\Auto-it\Auto-it3

AT005

    Topic Starter


    Rookie

    Re: Command Prompt (CMD); Two issues about DIR command
    « Reply #16 on: November 28, 2009, 09:26:14 AM »
    hello?

    AT005

      Topic Starter


      Rookie

      Re: Command Prompt (CMD); Two issues about DIR command
      « Reply #17 on: November 29, 2009, 04:35:43 AM »
      I tried with:

      Code: [Select]
      @echo off
      for /f "tokens=4,5 delims=\" %%a in ('dir /ad /s /b') do echo %%a\%%b

      instead of

      Code: [Select]
      @echo off
      for /f "tokens=4,5 delims=\" %%a in ('dir /ad /s /b') do echo %%a\%%b
      pause

      But even this doesn't do anything.  :(

      Salmon Trout

      • Guest
      Re: Command Prompt (CMD); Two issues about DIR command
      « Reply #18 on: November 29, 2009, 05:50:07 AM »
      You are doing something wrong. We do not know what, since you don't give enough information.


      AT005

        Topic Starter


        Rookie

        Re: Command Prompt (CMD); Two issues about DIR command
        « Reply #19 on: November 29, 2009, 08:44:38 AM »
        You are doing something wrong. We do not know what, since you don't give enough information.

        I have tried to use the both codes - of course NOT at the same time. I have pasted them to notepad, each time i saved them as .bat. Firstly used second code but since it doesn't work, I used first one but doesn't work too - two .doc files are still not created. What I wish to have in .doc files is described in my first and second post.

        Salmon Trout

        • Guest
        Re: Command Prompt (CMD); Two issues about DIR command
        « Reply #20 on: November 29, 2009, 08:47:31 AM »
        You left the > filename.doc off the end.

        AT005

          Topic Starter


          Rookie

          Re: Command Prompt (CMD); Two issues about DIR command
          « Reply #21 on: November 29, 2009, 08:52:06 AM »
          If you meant this:

          Code: [Select]
          @echo off
          for /f "tokens=4,5 delims=\" %%a in ('dir /ad /s /b') do echo %%a\%%b > filename.doc
          pause

          It does give me the .doc file but just one instead of two and with terrible results inside - completely different from what I was asking  ???

          Salmon Trout

          • Guest
          Re: Command Prompt (CMD); Two issues about DIR command
          « Reply #22 on: November 29, 2009, 08:54:41 AM »
          I think you are going to have to learn some batch scripting

          AT005

            Topic Starter


            Rookie

            Re: Command Prompt (CMD); Two issues about DIR command
            « Reply #23 on: December 04, 2009, 01:30:47 PM »
            Why nobody wants to tell me what should I do, in my situation, described in first and third post?  :(