D
D
Djasar2021-03-09 09:55:45
cmd/bat
Djasar, 2021-03-09 09:55:45

Need to find small files in different directories, how?

Not very strong in cmd, but sketched out a little code. I wanted to simplify it a little.
1. You need to search on a network drive
2. Do a search in different folders: by size
3. Output the search result to a text file with full paths to the file.

net use x: \\10.10.10.10\h$\katolog
ferfiles /P X:\papka1 M/ *.* /S /C "cmd /c if @fsize LSS 20 echo @path size @fsize date @fdate time @ftime" >C:\temp\1\text.txt "
ferfiles /P X:\papka2 M/ *.* /S /C "cmd /c if @fsize LSS 20 echo @path size @fsize date @fdate time @ftime" >C:\temp\1\text2.txt "
ferfiles /P X:\papka3 M/ *.* /S /C "cmd /c if @fsize LSS 20 echo @path size @fsize date @fdate time @ftime" >C:\temp\1\text3.txt "
net use x: /d


4. You cannot specify the entire katolog, because there are folders that do not need to be scanned
5. And you need to save the entire result by folders in one file, and not in several like mine.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
pumpkinm, 2021-03-10
@Djasar

del /q out.txt
for /R "\\SERVER1\Share1\Folder1" %%A in (*.*) do if %%~zA LSS 20 echo %%A [size %%~zA] >> out.txt
for /R "\\SERVER2\Share2\Folder2" %%A in (*.*) do if %%~zA LSS 20 echo %%A [size %%~zA] >> out.txt
for /R "\\SERVER3\Share3\Folder3" %%A in (*.*) do if %%~zA LSS 20 echo %%A [size %%~zA] >> out.txt

W
wisgest, 2021-03-09
@wisgest

forfiles- an external utility that is not installed everywhere, and, frankly, I don’t know why it’s needed, since, at least in most cases, everything that can be done with it can be done with an internal command for- I advise you to study the help:
for /?

And you need to save the entire result by folders in one file, and not in several like mine.

Or group commands: instead of
comand1>file.txt
comand2>file.txt

write
(
  comand1
  comand2
)>file.txt

or use >>instead >to append to a file without clearing it:
comand1>file.txt
comand2>>file.txt

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question