itapolda
Goto Top

formatierte Ausgabe mit echo nach Rechnen mit set

Hallo!

Folgende Batch Datei:

@echo off
set /a size=0
for /R "%USERPROFILE%\Eigene Dateien\" %%i in (*.*) do (  
set /a fsize=%%~zi
set /a size=size+fsize
)
echo Size von %USERPROFILE% : %size% >> Daten.txt

gibt folgendes aus:

Size von ... : -1671295726


Wie kann ich die Dateigröße so formatieren, dass ich was damit anfangen kann?
Zum Beispiel in MB oder KB?

Hoffe es kann mir jemand helfen.

Gruß


edit:

Wahrscheinlich sind es zu viele Dateien und die Dateigröße zu groß.
Welche Grenze gibt es denn da?

Content-Key: 60501

Url: https://administrator.de/contentid/60501

Printed on: April 16, 2024 at 11:04 o'clock

Mitglied: 22736
22736 Jun 04, 2007 at 20:34:48 (UTC)
Goto Top
Hallo.

Ich würde es mir nicht so schwer machen. Vielleicht ist DIRUSE (ein Windows Support Tool) genau das richtige für Dich:

DIRUSE displays a list of disk usage for a directory tree(s). Version 1.20

DIRUSE [/S | /V] [/M | /K | /B] [/C] [/,] [/Q:# [/L] [/A] [/D] [/O]] [/*] DIRS

/S Specifies whether subdirectories are included in the output.
/V Output progress reports while scanning subdirectories. Ignored if /S is
specified.
/M Displays disk usage in megabytes.
/K Displays disk usage in kilobytes.
/B Displays disk usage in bytes (default).
/C Use Compressed size instead of apparent size.
/, Use thousand separator when displaying sizes.
/L Output overflows to logfile .\DIRUSE.LOG.
/* Uses the top-level directories residing in the specified DIRS
/Q:# Mark directories that exceed the specified size (#) with a "!".
(If /M or /K is not specified, then bytes is assumed.)
/A Specifies that an alert is generated if specified sizes are exceeded.
(The Alerter service must be running.)
/D Displays only directories that exceed specified sizes.
/O Specifies that subdirectories are not checked for specified size
overflow.
DIRS Specifies a list of the paths to check.

Note: Parameters can be typed in any order. And the '-' symbol can be
used in place of the '/' symbol.

Also, if /Q is specified, then return code is ONE if any directories are
found that
exceed the specified sizes. Otherwise the return code is ZERO.

Example: diruse /s /m /q:1.5 /l /* c:\users
Member: ITApolda
ITApolda Jun 05, 2007 at 06:46:57 (UTC)
Goto Top
Vielen Dank für deine Antwort.

Ich wollte aber eigentlich über eine Gruppenrichtlinie die batch ausführen lassen und bei dem Tool muss es sicherlich installiert sein, oder?

Habe es nun auch hinbekommen.
Ich rechne die Dateigröße gleich in MB um. So komme ich auf keine große Zahl und es funktioniert mit rechnen. face-smile

Hier die Lösung:

@echo off
set /a size=0
echo %COMPUTERNAME% > %COMPUTERNAME%.txt
for /R "%USERPROFILE\Eigene Dateien" %%i in (*.*) do (  
set /a fsize=%%~zi/1048576 
set /a size=size+fsize
)
echo Size von %USERPROFILE% ist %size% MB  >> %COMPUTERNAME%.txt
exit