Page 1 of 1
[Help] Script log file size.
Posted: 31 Oct 2013 11:35
by romanrsr
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!
Re: [Help] Script log file size.
Posted: 31 Oct 2013 15:59
by Squashman
do you want it to recurse through sub directories or do you really want just one folder.
Re: [Help] Script log file size.
Posted: 31 Oct 2013 22:21
by b8two
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"
Output
Code: Select all
1 File(s) 26,738 bytes IN C:\Users
Re: [Help] Script log file size.
Posted: 01 Nov 2013 08:34
by romanrsr
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"
Output
Code: 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.
Posted: 01 Nov 2013 08:35
by romanrsr
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.
Posted: 01 Nov 2013 11:25
by aGerman
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
Re: [Help] Script log file size.
Posted: 01 Nov 2013 13:01
by romanrsr
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.
Posted: 01 Nov 2013 13:05
by Squashman
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.
Posted: 04 Nov 2013 06:51
by romanrsr
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.
Posted: 04 Nov 2013 16:29
by foxidrive
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.