Answer the question
In order to leave comments, you need to log in
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
Answer the question
In order to leave comments, you need to log in
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
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.
comand1>file.txt
comand2>file.txt
(
comand1
comand2
)>file.txt
>>
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 questionAsk a Question
731 491 924 answers to any question