I need to monitor a folder in windows Server. This folder gets updated every time. I need to get the size of the file and file name inside this folder - Just by running a script.


You can do this from the command line like this:

for %I in (test.jpg) do @echo %~zI

You can also pass in a file mask to get a listing for more than one file:

for %I in (*.doc) do @echo %~znI

Will display the size, file name of each .DOC file.

Use below line to display size of all the files as well as file name inside a directory.

for %I in (*) do @echo %~znI

If sub-folders do not need it, command-line:

dir "<folder path>" /A:-D

You can also use



you retive all files in the directory with the following attributes:

Mode                LastWriteTime     Length Name

If you need only the filename and the size you can use

Get-ChildItem | Format-Table Name,Length

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.