1.

Solve : DIR - DiscLetter?

Answer»

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.txtbut 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:"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
lol why i dont thinked about it ??  i tried to do harder work but anyway thanksglad i could help.

 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
)
)
yup thanks Dias what is the /i switch?  Or is it even a switch? Quote from: qz33 on March 28, 2008, 01:57:28 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.



Discussion

No Comment Found