Check File Size Properties

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
xiro
Posts: 34
Joined: 21 May 2014 00:17

Check File Size Properties

#1 Post by xiro » 08 Feb 2023 19:45

Is it possible to view folder size properties with a right click using a batch file for comparison to folders? I am researching it now what key phrase should I type to find nice result for this project?


Image

Where it could open the right click and show me the properties window is this possible?

xiro
Posts: 34
Joined: 21 May 2014 00:17

Re: Check File Size Properties

#2 Post by xiro » 21 Feb 2023 01:03

I guess this is not possible sad. Tsk!

Sponge Belly
Posts: 231
Joined: 01 Oct 2012 13:32
Location: Ireland
Contact:

Re: Check File Size Properties

#3 Post by Sponge Belly » 25 Feb 2023 08:47

Hi Xiro! :)

Please read this Microsoft Community thread.

HTH!

- SB

xiro
Posts: 34
Joined: 21 May 2014 00:17

Re: Check File Size Properties

#4 Post by xiro » 06 Mar 2023 20:14

Sponge Belly wrote:
25 Feb 2023 08:47
Hi Xiro! :)

Please read this Microsoft Community thread.

HTH!

- SB
Haha..... How to do that with a batch file to choose a folder then know their sizes by just clicking the .bat file and the properties window would show up and I can now Identify if it both folder are of same size :)

xiro
Posts: 34
Joined: 21 May 2014 00:17

Re: Check File Size Properties

#5 Post by xiro » 06 Mar 2023 20:14

xiro wrote:
06 Mar 2023 20:14
Sponge Belly wrote:
25 Feb 2023 08:47
Hi Xiro! :)

Please read this Microsoft Community thread.

HTH!

- SB
Haha..... How to do that with a batch file to choose a folder then know their sizes by just clicking the .bat file and the properties window would show up and I can now Identify if it both folder are of same size :)

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Check File Size Properties

#6 Post by ShadowThief » 06 Mar 2023 23:22

I don't understand why you need this. Just right-click the first folder and select Properties, and then right-click the second folder and select Properties. There's no need to bring a script into this at all based on what you've described so far.

xiro
Posts: 34
Joined: 21 May 2014 00:17

Re: Check File Size Properties

#7 Post by xiro » 07 Mar 2023 02:12

ShadowThief wrote:
06 Mar 2023 23:22
I don't understand why you need this. Just right-click the first folder and select Properties, and then right-click the second folder and select Properties. There's no need to bring a script into this at all based on what you've described so far.
That is for automation where I don't need to bother with any right click and I will attach that fragment code to the script that I have created in automating the backup of the company database :)

The sole purpose for the right-click function is that I could easily see if the backup has the same size as the source file just by looking at it early in the morning when I arrive. :D

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Check File Size Properties

#8 Post by ShadowThief » 07 Mar 2023 22:30

If all you need is the size of some folder, that's been posted on here before: viewtopic.php?t=9615

xiro
Posts: 34
Joined: 21 May 2014 00:17

Re: Check File Size Properties

#9 Post by xiro » 08 Mar 2023 07:55

ShadowThief wrote:
07 Mar 2023 22:30
If all you need is the size of some folder, that's been posted on here before: viewtopic.php?t=9615
I will try this thank you for your assistance pal😐

xiro
Posts: 34
Joined: 21 May 2014 00:17

Re: Check File Size Properties

#10 Post by xiro » 08 Mar 2023 07:55

ShadowThief wrote:
07 Mar 2023 22:30
If all you need is the size of some folder, that's been posted on here before: viewtopic.php?t=9615
I will try this thank you for your assistance pal😐

xiro
Posts: 34
Joined: 21 May 2014 00:17

Re: Check File Size Properties

#11 Post by xiro » 10 Mar 2023 01:24

@echo off
setlocal

set "folder1=C:"
set "folder2=E:"

set "size1="
set "size2="

for /f "tokens=1,2 delims=: " %%a in ('robocopy "%folder1%" "%folder1%" /L /S /NJH /BYTES /FP /NC /NDL /NFL /TS /XJ /R:0 /W:0') do if /i "%%a"=="Bytes" set "size1=%%b"

for /f "tokens=1,2 delims=: " %%a in ('robocopy "%folder2%" "%folder2%" /L /S /NJH /BYTES /FP /NC /NDL /NFL /TS /XJ /R:0 /W:0') do if /i "%%a"=="Bytes" set "size2=%%b"

if "%size1%"=="" (echo Error: Unable to get size for folder "%folder1%" & goto :EOF)
if "%size2%"=="" (echo Error: Unable to get size for folder "%folder2%" & goto :EOF)

echo Folder 1: %folder1%
echo Size: %size1% bytes
echo.
echo Folder 2: %folder2%
echo Size: %size2% bytes
echo.

if %size1% GTR %size2% (
echo Folder 1 is larger than Folder 2
) else if %size1% LSS %size2% (
echo Folder 2 is larger than Folder 1
) else (
echo Folder 1 and Folder 2 are the same size
)

Not that accurate why?

xiro
Posts: 34
Joined: 21 May 2014 00:17

Re: Check File Size Properties

#12 Post by xiro » 15 Mar 2023 23:49

gulshan212 wrote:
14 Mar 2023 22:45
Hello this is Gulshan Negi
Well, to view folder size properties with a right click using a batch file, you can create a batch script that uses the Windows PowerShell command-line interface. To find resources and information related to this topic, you can search for phrases like "batch script to get folder size" or "Windows PowerShell folder size". You can also check online forums and communities like Stack Overflow and Microsoft Tech Community for helpful tips and guidance.
I hope you are clear now.
Thanks
Thanks cool.

xiro
Posts: 34
Joined: 21 May 2014 00:17

Re: Check File Size Properties

#13 Post by xiro » 17 Mar 2023 00:48

I have now the sample script

$folder1 = Get-ChildItem -Path "E:\XXX\Videos" -Recurse | Measure-Object -Property Length -Sum
$folder2 = Get-ChildItem -Path "F:\NEWLYCREATED FOLDER" -Recurse | Measure-Object -Property Length -Sum

if ($folder1.Sum -gt $folder2.Sum) {
Write-Host "Folder1 is larger than Folder2 by $(($folder1.Sum / 1MB).ToString('N2')) MB"
} elseif ($folder1.Sum -lt $folder2.Sum) {
Write-Host "Folder2 is larger than Folder1 by $(($folder2.Sum / 1MB).ToString('N2')) MB"
} else {
Write-Host "Folder1 and Folder2 are the same size"
}

In the folder2 how to check the new folder created within this day? Am I needed to %NewFolder%? How? Heheh Folder2 is a newly created folder, not an old folder.

The above script works only if the folder was already created, but how about a daily folder creation (Folder2) then checking the folder size within the same day is not possible because that is another folder name that is only the lacking piece and boom its done :)

Any help is acceptable

Post Reply