Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how can we sort files according to their size using cmd batch files and print a wait timer till the loop is running?

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 ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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.
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading