Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: accessing properties from dos command line  (Read 3977 times)

0 Members and 1 Guest are viewing this topic.

thecottonginny

  • Guest
accessing properties from dos command line
« on: August 10, 2007, 12:41:09 PM »
1.  I need to figure out how to access the properties tab from the command line. 

Basically, I am trying to use some of the info in properties (specifically, the width and height of a video file) for inclusion in a script (python, calling os.system to use the command line).  So, instead of right-clicking, selecting properties, clicking on summary, and looking at width and height under "image" to get the dimensions, I like to see if I can get the width and height (or all properties, whatever) printed out to the screen (to be redirected to a text file and read in to the script.)

I know you can use "dir" and the filename to find the size, but I absolutely cannot figure out how to display any other properties.

2.  A less important question, and possibly something better answered for python than for dos, but something else I'm trying to figure out: what's the best way to distinguish between directories and files in a folder?  I'm looking for something like an "isDirectory()" kind of function.

Thanks.

ghostdog74



    Specialist

    Thanked: 27
    Re: accessing properties from dos command line
    « Reply #1 on: August 10, 2007, 09:40:14 PM »
    Quote from: thecottonginny
    1.  I need to figure out how to access the properties tab from the command line. 
    you can use vbscript:
    Code: [Select]
    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.Namespace("C:\temp")
    For Each strFileName in objFolder.Items
        If strFileName = "myVideo.avi" Then
        For i = 0 to 34
        WScript.Echo i, objFolder.GetDetailsOf(strFileName,i)
        Next
        Exit For
        End If
    Next
    save as myscript.vbs and on command prompt, type cscript /nologo myscript.vbs
    output:
    Code: [Select]
    Microsoft (R) Windows Script Host Version 5.6
    Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

    0 myVideo.avi
    1 418 KB
    2 Video Clip
    3 3/19/2002 5:26 AM
    4 8/11/2007 11:06 AM
    5 8/11/2007 11:06 AM
    6 RA
    7 Online
    8 MYNEWNAME\Administrator
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21 0:00:00
    22
    23
    24
    25
    26 1024 x 768
    27 1024 pixels
    28 768 pixels
    29
    30
    31
    32
    33
    34
    you can see that index 26-28 contains the video information

    Quote
    2.  A less important question, and possibly something better answered for python than for dos, but something else I'm trying to figure out: what's the best way to distinguish between directories and files in a folder?  I'm looking for something like an "isDirectory()" kind of function.

    check out the Python docs for os.path module.
    Basically, to check if its a file, use os.path.isfile(), or directory use os.path.isdir()
    « Last Edit: August 22, 2007, 05:25:33 PM by ghostdog74 »

    thecottonginny

    • Guest
    Re: accessing properties from dos command line
    « Reply #2 on: August 22, 2007, 12:11:51 PM »
    Thank you!  This reply is ages late, but it took awhile before it was necessary for me to implement this code.

    Also, there's one change to make here, at least on my computer:

    "myVideo.avi" should be changed to "myVideo" - for whatever reason, you don't include the extension.  This wasn't a problem for me (once I figured it out!) but may be a problem for others if they have multiple files with the same name but different extensions.  On files with the same name it will pick the avi file though, I guess because it's earlier in the alphabet.