Advertisements
How can we sorting the files with size in the decreasing order.
What should i add ?
for %%d 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 %%d: ( echo Another process is running !! Please wait !!! && dir %%d:\ /s >> %Systeminfo_TXT%))
And if I want to print a timer till the time loop is running, how can i do that ?
>Solution :
To sort the files by size in decreasing order, you can add the "/o:-s
option to the "dir" command.
for %%d 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 %%d: (
echo Listing files in %%d:
dir %%d:\ /s /o:-s >> %Systeminfo_TXT%
)
)
To print a message while the loop is running, you can use the "echo" command as you suggested.
@echo off
set Systeminfo_TXT=output.txt
echo Starting file listing...
for %%d 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 %%d: (
echo Listing files in %%d...
dir %%d:\ /s /o:-s >> %Systeminfo_TXT%
)
)
echo File listing complete.