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

Author Topic: DIR - DiscLetter  (Read 3501 times)

0 Members and 1 Guest are viewing this topic.

devcom

    Topic Starter


    Apprentice

    Thanked: 37
    DIR - DiscLetter
    « on: March 27, 2008, 07:51:10 AM »
    how can do for loop which will do sth like this:
    Code: [Select]
    echo.>DIR.txt
    echo.---------------------------------------------------------------------- >>DIR.txt
    echo.                               "A" DRIVE >>DIR.txt
    echo.---------------------------------------------------------------------- >>DIR.txt
    echo. >>DIR.txt
    echo.--- RAR --- >>DIR.txt
    dir A:\*.rar /s /b >>DIR.txt
    echo.--- LOG --- >>DIR.txt
    dir A:\*.log /s /b >>DIR.txt
    echo.--- TXT --- >>DIR.txt
    dir A:\*.txt /s /b >>DIR.txt
    echo.--- BAT--- >>DIR.txt
    dir A:\*.bat /s /b >>DIR.txt
    echo.--- ZIP --->>DIR.txt
    dir A:\*.zip /s /b >>DIR.txt
    echo.--- DAT --->>DIR.txt
    dir A:\*.dat /s /b >>DIR.txt
    echo.--- VBS --- >>DIR.txt
    dir A:\*.vbs /s /b >>DIR.txt
    echo.--- PAK --- >>DIR.txt
    dir A:\*.pak /s /b >>DIR.txt
    but for all founded discs on computer ?
    i have code which find selected drive but in this method i have file with 50000 letters so i want to do it with for loop but dunno how
    Code: [Select]
    wmic volume get DriveLetter |findstr "A:"
    Download: Choice.exe

    blastman



      Hopeful

      Re: DIR - DiscLetter
      « Reply #1 on: March 27, 2008, 11:29:24 AM »
      nice.

      I fancied a little project for an hour or so...

      here you go;

      Code: [Select]
      @echo off

      set /a count=1

      :loop

      if /i %count% EQU 1 (set Letter=A)
      if /i %count% EQU 2 (set Letter=B)
      if /i %count% EQU 3 (set Letter=C)
      if /i %count% EQU 4 (set Letter=D)
      if /i %count% EQU 5 (set Letter=E)
      if /i %count% EQU 6 (set Letter=F)
      if /i %count% EQU 7 (set Letter=G)
      if /i %count% EQU 8 (set Letter=H)
      if /i %count% EQU 9 (set Letter=I)
      if /i %count% EQU 10 (set Letter=J)
      if /i %count% EQU 12 (set Letter=K)
      if /i %count% EQU 13 (set Letter=L)
      if /i %count% EQU 14 (set Letter=O)
      if /i %count% EQU 15 (set Letter=M)
      if /i %count% EQU 16 (set Letter=N)
      if /i %count% EQU 17 (set Letter=P)
      if /i %count% EQU 18 (set Letter=Q)
      if /i %count% EQU 19 (set Letter=R)
      if /i %count% EQU 20 (set Letter=S)
      if /i %count% EQU 21 (set Letter=T)
      if /i %count% EQU 22 (set Letter=U)
      if /i %count% EQU 23 (set Letter=V)
      if /i %count% EQU 24 (set Letter=X)
      if /i %count% EQU 25 (set Letter=Y)
      if /i %count% EQU 26 (set Letter=Z)


      dir %Letter%: >nul

      if /i %errorlevel% GTR 0 (echo.Unable to list %Letter%: Drive>>C:\ErrorLog.txt & goto next)

      dir %Letter%: >c:\%Letter%Drive.txt


      ping localhost -n 5 >nul




      :next

      set /a count +=1

      if /i %count% EQU 27 (goto end)

      goto loop






      :end

      cls
      echo.End of Script.

      pause>nul
      exit


      Blastman, you are the man. Thank You Very Much!!!!!!!!!



      devcom

        Topic Starter


        Apprentice

        Thanked: 37
        Re: DIR - DiscLetter
        « Reply #2 on: March 27, 2008, 11:38:37 AM »
        lol why i dont thinked about it ??  :-X i tried to do harder work but anyway thanks
        Download: Choice.exe

        blastman



          Hopeful

          Re: DIR - DiscLetter
          « Reply #3 on: March 27, 2008, 11:46:45 AM »
          glad i could help.

           ;)

          Blastman, you are the man. Thank You Very Much!!!!!!!!!



          Dias de verano

          • Guest
          Re: DIR - DiscLetter
          « Reply #4 on: March 27, 2008, 12:23:01 PM »
          This is where FOR is useful.

          Code: [Select]
          @echo off
          echo.>DIR.txt
          for %%L in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
          if exist %%L:\ (
          echo.---------------------------------------------------------------------- >>DIR.txt
          echo.                               "%%L" DRIVE >>DIR.txt
          echo.---------------------------------------------------------------------- >>DIR.txt
          echo. >>DIR.txt
          echo.--- RAR --- >>DIR.txt
          dir %%L:\*.rar /s /b >>DIR.txt
          echo.--- LOG --- >>DIR.txt
          dir %%L:\*.log /s /b >>DIR.txt
          echo.--- TXT --- >>DIR.txt
          dir %%L:\*.txt /s /b >>DIR.txt
          echo.--- BAT--- >>DIR.txt
          dir %%L:\*.bat /s /b >>DIR.txt
          echo.--- ZIP --->>DIR.txt
          dir %%L:\*.zip /s /b >>DIR.txt
          echo.--- DAT --->>DIR.txt
          dir %%L:\*.dat /s /b >>DIR.txt
          echo.--- VBS --- >>DIR.txt
          dir %%L:\*.vbs /s /b >>DIR.txt
          echo.--- PAK --- >>DIR.txt
          dir %%L:\*.pak /s /b >>DIR.txt
          )
          )

          devcom

            Topic Starter


            Apprentice

            Thanked: 37
            Re: DIR - DiscLetter
            « Reply #5 on: March 27, 2008, 02:13:36 PM »
            yup thanks Dias
            Download: Choice.exe

            qz33



              Rookie
              Re: DIR - DiscLetter
              « Reply #6 on: March 28, 2008, 01:57:28 PM »
              what is the /i switch?  Or is it even a switch?

              Dias de verano

              • Guest
              Re: DIR - DiscLetter
              « Reply #7 on: March 28, 2008, 02:01:15 PM »
              what is the /i switch?  Or is it even a switch?

              if you type IF /? at the prompt you'll find out. Strictly speaking it was unecessary in the post above where you saw it.