directory recurse per l'estensione di file con totale?
-
19-09-2019 - |
Domanda
Vorrei sapere quanto spazio su disco viene utilizzato da file zip (o qualsiasi altra estensione) in un particolare albero di directory. Questo è possibile sulla riga di comando (in un programma batch)?
Io li posso elencare, vale a dire: dir / s * .zip o utilizzando "forfiles": forfiles / p d: \ WINCAP / s / m * .zip / c "cmd / c echo @fsize"
ho bisogno in un programma batch, perché voglio eseguirlo su più di 100 server (W2K3). Io sono abituato a Unix / Linux, e dos mi sta dando un mal di testa;)
idee?
Grazie! Ron
Soluzione
Ecco una versione modificata di quella che si trova: http: // en.kioskea.net/forum/affich-42442-dos-command-batch-file-to-find-a-folder-size
@echo off
setLocal EnableDelayedExpansion
set /a value=0
set /a sum=0
FOR /R %1 %%I IN (%2) DO (
set /a value=%%~zI/1024/1024
set /a sum=!sum!+!value!
)
@echo Size is: !sum! MB
Al fine di evitare overflow che converte i valori a MB subito in modo che arrotonderà e quindi il totale, ma spero che questo ti mette sulla strada giusta sotto-report, almeno. Salvarlo come dirsize.bat
e chiamarlo con la directory come primo parametro e il modello per abbinare come il secondo:
dirsize c:\ *.zip
Altri suggerimenti
Si può provare a comando comando, forse può aiutare a gestire in remoto.
Esempio: sul prompt di DOS > at \\localhost dir /s *.zip
scrittura (localhost può essere 192.bla.bla.bla, ciò che si desidera chiamare remoto)
Guida Ulteriori
The AT command schedules commands and programs to run on a computer at
a specified time and date. The Schedule service must be running to use
the AT command.
AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
AT [\\computername] time [/INTERACTIVE]
[ /EVERY:date[,...] | /NEXT:date[,...]] "command"
\\computername Specifies a remote computer. Commands are scheduled on the
local computer if this parameter is omitted.
id Is an identification number assigned to a scheduled
command.
/delete Cancels a scheduled command. If id is omitted, all the
scheduled commands on the computer are canceled.
/yes Used with cancel all jobs command when no further
confirmation is desired.
time Specifies the time when command is to run.
/interactive Allows the job to interact with the desktop of the user
who is logged on at the time the job runs.
/every:date[,...] Runs the command on each specified day(s) of the week or
month. If date is omitted, the current day of the month
is assumed.
/next:date[,...] Runs the specified command on the next occurrence of the
day (for example, next Thursday). If date is omitted, the
current day of the month is assumed.
"command" Is the Windows NT command, or batch program to be run.
se è possibile scaricare gli animali al vostro computer, è comunque possibile utilizzare strumenti Unix, come du.
du *zip