[Help] Script log file size.
Moderator: DosItHelp
[Help] Script log file size.
Hello friends, how are you? First of all sorry for my poor English.
As it says in the title, you would need a script that loops through all the files and folders in a directory, and I generate a log with the size of each file and folder. Is there any way?
Thank you!
Greetings!
As it says in the title, you would need a script that loops through all the files and folders in a directory, and I generate a log with the size of each file and folder. Is there any way?
Thank you!
Greetings!
Re: [Help] Script log file size.
do you want it to recurse through sub directories or do you really want just one folder.
Re: [Help] Script log file size.
For the Size of each folder;
Current folder only;
All sub folders from current for in a batch file;
All sub folders from current in the Command Prompt;
Output
Current folder only;
Code: Select all
dir /A-D %A\*.*^|find "File(s)" 2>nul 1>"File List.txt"
All sub folders from current for in a batch file;
Code: Select all
for /f "tokens=*" %%A IN ('dir /b /s /ad') DO (for /f "tokens=*" %%a IN ('dir /A-D %%A\*.*^|find "File(s)"') DO ECHO %%a IN %%A) 2>nul 1>"File List.txt"
All sub folders from current in the Command Prompt;
Code: Select all
for /f "tokens=*" %A IN ('dir /b /s /ad') DO (for /f "tokens=*" %a IN ('dir /A-D %A\*.*^|find "File(s)"') DO ECHO %a IN %A) 2>nul 1>"File List.txt"
Output
Code: Select all
1 File(s) 26,738 bytes IN C:\Users
Re: [Help] Script log file size.
b8two wrote:For the Size of each folder;
Current folder only;Code: Select all
dir /A-D %A\*.*^|find "File(s)" 2>nul 1>"File List.txt"
All sub folders from current for in a batch file;Code: Select all
for /f "tokens=*" %%A IN ('dir /b /s /ad') DO (for /f "tokens=*" %%a IN ('dir /A-D %%A\*.*^|find "File(s)"') DO ECHO %%a IN %%A) 2>nul 1>"File List.txt"
All sub folders from current in the Command Prompt;Code: Select all
for /f "tokens=*" %A IN ('dir /b /s /ad') DO (for /f "tokens=*" %a IN ('dir /A-D %A\*.*^|find "File(s)"') DO ECHO %a IN %A) 2>nul 1>"File List.txt"
OutputCode: Select all
1 File(s) 26,738 bytes IN C:\Users
Thank you very much friend!
I just run the script, but it generates the. Txt blank, we must add something more to the script?
Greetings!
Re: [Help] Script log file size.
Squashman wrote:do you want it to recurse through sub directories or do you really want just one folder.
I want to recurse the files and folders in a directory. Thank you!
Greetings!
Re: [Help] Script log file size.
Could it be we are thinking too complicated
@romanrsr
Would that be sufficient for you?
Change the "C:\your\folder" to the path that you want to log.
Regards
aGerman
@romanrsr
Would that be sufficient for you?
Code: Select all
>"logfile.log" dir /a /s "C:\your\folder"
Change the "C:\your\folder" to the path that you want to log.
Regards
aGerman
Re: [Help] Script log file size.
aGerman wrote:Could it be we are thinking too complicated
@romanrsr
Would that be sufficient for you?Code: Select all
>"logfile.log" dir /a /s "C:\your\folder"
Change the "C:\your\folder" to the path that you want to log.
Regards
aGerman
Unfortunately not work for me friend, archive.log opens, but does not generate anything inside.
Thank you!
Greetings!
Re: [Help] Script log file size.
romanrsr wrote:aGerman wrote:Could it be we are thinking too complicated
@romanrsr
Would that be sufficient for you?Code: Select all
>"logfile.log" dir /a /s "C:\your\folder"
Change the "C:\your\folder" to the path that you want to log.
Regards
aGerman
Unfortunately not work for me friend, archive.log opens, but does not generate anything inside.
Thank you!
Greetings!
That code will work just fine. Show us exactly how you used it.
Re: [Help] Script log file size.
Squashman wrote:romanrsr wrote:aGerman wrote:Could it be we are thinking too complicated
@romanrsr
Would that be sufficient for you?Code: Select all
>"logfile.log" dir /a /s "C:\your\folder"
Change the "C:\your\folder" to the path that you want to log.
Regards
aGerman
Unfortunately not work for me friend, archive.log opens, but does not generate anything inside.
Thank you!
Greetings!
That code will work just fine. Show us exactly how you used it.
This is the script that runs: >"logfile.log" dir /a /s "C:\data"
Re: [Help] Script log file size.
romanrsr wrote:This is the script that runs: >"logfile.log" dir /a /s "C:\data"
Two things can stop that running:
A) the logfile is being written to a place where you don't have write permissions, such as c:\
B) c:\data doesn't exist
You can test this by opening a cmd prompt and typing the command you listed above - you will get an error message or the logfile will contain the results.