Was wondering if anyone out there know a better way to do this?
@echo off
for /f "tokens=2 delims= " %%a in ('date /T') do (set date=%%a)
for /f "tokens=1,2 delims= " %%b in ('time /T') do (set time=%%b)
pushd "R:\"
for /f "tokens=3 delims= " %%e in ('dir /s /w ^| find /i "File(s)"') do (set dept_dir_size=%%e)
popd
echo %date% %time% - Department - %dept_dir_size%
echo %date% %time% - Department - %dept_dir_size% >> c:\List.txt
Directory Size?
Moderator: DosItHelp
Re: Directory Size?
This will give you a more accurate file count but it will only count all files on the drive that the user account has permissions to list.
Code: Select all
@echo off
dir R:\ /b /s /a-d 2>nul >%temp%\files.txt
for /f "delims=" %%e in ('find /c /v "" ^<%temp%\files.txt') do (
echo %date% %time% - Department - %%e
>>c:\List.txt echo %date% %time% - Department - %%e
)
del %temp%\files.txt
pause
-
- Posts: 6
- Joined: 17 Aug 2012 15:32
Re: Directory Size?
I realized after the fact that I didn't really make it clear what I was trying to do. I'm trying to get the size of the directory including all the sub directories.
Re: Directory Size?
Drive size minus freespace?
-
- Posts: 6
- Joined: 17 Aug 2012 15:32
Re: Directory Size?
Ya, that work normally. This is unfortunately a Network share and the share is not the root of all the folders.
Re: Directory Size?
This is similar to your technique but should be faster on large subdirectories.
Code: Select all
@echo off
dir r:\ /s /a-d 2>nul >%temp%\files.txt
for /f "tokens=3" %%e in ('find /i "File(s)" ^<%temp%\files.txt') do set total=%%e
echo %date% %time% - Department - %total%
>>c:\List.txt echo %date% %time% - Department - %total%
del %temp%\files.txt
Re: Directory Size?
@Yamanipanuchi
The size of a folder is nowhere saved. Try to display the properties of the Windows folder in your explorer window. It takes some time to get the number of files / folders and the folder size. That means it loops recursively across the folder to collect the data step by step. That's the same like DIR /S does. I assume there is no better way.
Regards
aGerman
The size of a folder is nowhere saved. Try to display the properties of the Windows folder in your explorer window. It takes some time to get the number of files / folders and the folder size. That means it loops recursively across the folder to collect the data step by step. That's the same like DIR /S does. I assume there is no better way.
Regards
aGerman