[Help] Script log file size.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
romanrsr
Posts: 7
Joined: 30 Jan 2013 06:55

[Help] Script log file size.

#1 Post by romanrsr » 31 Oct 2013 11:35

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!

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: [Help] Script log file size.

#2 Post by Squashman » 31 Oct 2013 15:59

do you want it to recurse through sub directories or do you really want just one folder.

b8two
Posts: 5
Joined: 31 Oct 2013 00:12

Re: [Help] Script log file size.

#3 Post by b8two » 31 Oct 2013 22:21

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

romanrsr
Posts: 7
Joined: 30 Jan 2013 06:55

Re: [Help] Script log file size.

#4 Post by romanrsr » 01 Nov 2013 08:34

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!

romanrsr
Posts: 7
Joined: 30 Jan 2013 06:55

Re: [Help] Script log file size.

#5 Post by romanrsr » 01 Nov 2013 08:35

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!

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: [Help] Script log file size.

#6 Post by aGerman » 01 Nov 2013 11:25

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

romanrsr
Posts: 7
Joined: 30 Jan 2013 06:55

Re: [Help] Script log file size.

#7 Post by romanrsr » 01 Nov 2013 13:01

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!

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: [Help] Script log file size.

#8 Post by Squashman » 01 Nov 2013 13:05

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.

romanrsr
Posts: 7
Joined: 30 Jan 2013 06:55

Re: [Help] Script log file size.

#9 Post by romanrsr » 04 Nov 2013 06:51

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"

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: [Help] Script log file size.

#10 Post by foxidrive » 04 Nov 2013 16:29

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.

Post Reply