5

Is there any command get all the properties of a file including its encoding format (this piece of information is really important to me) on Windows ? I'm looking for something similar to stat in Linux

I'd prefer using a command that can be used in command-prompt or a batch script although I know its possible with Powershell.

| |
9

You can use WMIC feature to do that.

For example :

F:>> wmic datafile where Name="anyfile.txt"

to get all information about anyfile.txt. You can use CMD and powershell too to using WMIC. And you can use GET parameter to get a specified information.

For Example:

F:>> wmic datafile where Name="F:\\ekojs.txt" get Description,Path,Status,Version

EDIT : Try using this before to check the WMIC functionality :

F:>> wmic datafile /?

To get a help how to using it.

Command :

wmic datafile where Name="F:\\ekojs.txt" get Description,Name,FileType >> eko_wmic.txt

Output in eko_wmic.txt:

Description   FileType       Name          
f:\ekojs.txt  Text Document  f:\ekojs.txt  

Hope this'll help you out..

| |
1

To build on the previous answer. You can use wmic datafile to get info about a file, but you have to provide the full path and double-up your slashes like so

wmic datafile where Name="F:\\anyfile.txt"

This gives an unreadable mess in the console, as you'll see:

what a great way to render data, wmic

However if you pipe this into a text file, it's pretty legible

wmic datafile where Name="F:\\anyfile.txt" >> fileprops.txt

enter image description here

Fortunately, wmic can format the info as a list, and then it is actually pretty useful.

wmic datafile where Name="F:\\anyfile.txt" list /format:list

enter image description here

You can then provide these properties only for a simplified view, note that you must remove the list keyword.

>wmic datafile where Name="G:\\ipcamera.log" get Hidden,FileSize,Name  /format:list


FileSize=20
Hidden=FALSE
Name=G:\ipcamera.log

A little piece of trivia, wmic was the foundation for what eventually became PowerShell!

| |
  • The wmic list display is quite useful; I used to use that same command but without the list part. For info on folders/directories, use wmic FSDIR where Name="C:\\path\\to\\folder" list /format:list. Online docs: ss64.com/nt/wmic.html – Rublacava 1 min ago

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.