Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Set and get extended file properties from command line

14,131 views
Skip to first unread message

Martin Heller

unread,
Jan 10, 2012, 7:42:44 AM1/10/12
to
Is it possible to set and/or get the extended file properties from the
command line?

By extended file properties I mean the properties that can be seen if
you right-click a file in Explorer -> Select Properties -> Select the
Summary tab.

The specific fields depend on file type, but for most file types
"Title", "Subject", "Author", "Category", "Keywords" and "Comments" are
available.

I use Win XP and Win 7 if that makes a difference.

foxidrive

unread,
Jan 10, 2012, 7:52:39 AM1/10/12
to
This might help - doesn't seem to understand long filenames so use the 8.3 name or wildcards

There is filedata.exe too and you might find updated versions, or look around for another utility.


FILEINFO.EXE 2.2 - Windows File Info - by Clay Ruth 04/12/1996 - 01/28/1999

FILEINFO filespec [/s]

Searches for standard Windows file information (StringFileInfo) and reports
the file name, date and time stamp, and size, followed by either a summary
of the found information or a statement that no other info is available.
Switch /s enables subdirectory searching.

Returns errorlevel 0 if info found, 1 if info not found, 2 if error.
When wildcards are used, highest level for the file group is returned.


c:\Program Files\Util>fileinfo.exe Everything.exe

No files matching pattern EVERYTHING.EXE

C:\PROGRA~1\Util>fileinfo.exe Every*.exe

File Name, Path: EVERYT~1.EXE C:\PROGRA~1\UTIL\EVERYT~1.EXE
Date, Time, Size: 03/13/2009 11:48:50 602624 Win32 EXE
Internal Name: Everything
Original Name: Everything.exe
File Description: Everything
File Version: 1, 2, 1, 371
Product Name: Everything
Product Version: 1, 2, 1, 371
Company Name: (n/a)
Copyright Info: Copyright (C) 2005-2008 David Carpenter


c:\Program Files\Util>filedata.exe Every*.exe
"FILENAME","FULLPATH","DATESTAMP","TIMESTAMP","SIZE","BITS","INTNAME","ORIGNAME"
,"DESCRIPTION","FVER","PRODUCT","PVER","OWNER","COPYRIGHT"
"EVERYT~1.EXE","C:\PROGRA~1\UTIL\EVERYT~1.EXE",03/13/2009,11:48:50,602624,32,"Ev
erything","Everything.exe","Everything","1, 2, 1, 371","Everything","1, 2, 1, 37
1","(n/a)","Copyright (C) 2005-2008 David Carpenter"




--
Regards,
Mic

Martin Heller

unread,
Jan 10, 2012, 8:27:35 AM1/10/12
to
foxidrive wrote, on 10-01-2012 13:52:
> This might help - doesn't seem to understand long filenames so use the 8.3 name or wildcards
>
> There is filedata.exe too and you might find updated versions, or look around for another utility.

Thanks. It helped a bit but I do have lots of files with long filenames
where I would like to access the properties.

I found this
<http://msdn.microsoft.com/en-us/library/windows/desktop/bb762231%28v=VS.85%29.aspx>


SHObjectProperties function:
Invokes the Properties context menu command on a Shell object.

However,

rundll32.exe shell32.dll,SHObjectProperties,<path to file>

gives no output. How do I invoke SHObjectProperties correctly from the
command line (if possible)?

foxidrive

unread,
Jan 10, 2012, 8:36:07 AM1/10/12
to
On 11/01/2012 00:27, Martin Heller wrote:
> foxidrive wrote, on 10-01-2012 13:52:
>> This might help - doesn't seem to understand long filenames so use the 8.3 name or wildcards
>>
>> There is filedata.exe too and you might find updated versions, or look around for another utility.
>
> Thanks. It helped a bit but I do have lots of files with long filenames
> where I would like to access the properties.

You can mostly use a for /f in do command and use the short filename with the utility and redirect it all into a file.

The %%~snx is buggy but tell us what you need to do and maybe something will work.




> I found this
> <http://msdn.microsoft.com/en-us/library/windows/desktop/bb762231%28v=VS.85%29.aspx>
>
>
> SHObjectProperties function:
> Invokes the Properties context menu command on a Shell object.
>
> However,
>
> rundll32.exe shell32.dll,SHObjectProperties,<path to file>
>
> gives no output. How do I invoke SHObjectProperties correctly from the
> command line (if possible)?

Unsure.


--
Regards,
Mic

Martin Heller

unread,
Jan 10, 2012, 9:39:43 AM1/10/12
to
foxidrive wrote, on 10-01-2012 14:36:
> You can mostly use a for /f in do command and use the short filename with the utility and redirect it all into a file.
>
> The %%~snx is buggy but tell us what you need to do and maybe something will work.


I cannot get it to work properly:

I have a txt file i c:\temp\test.txt

If I add the properties "Title=Foo" and "Author=Bar" from the Explorer
Properties Menu, then I can see these properties if I add them to the
detailed view in Explorer.

However, if I try filedata.exe or fileinfo.exe from a Command Prompt I
cannot see this information:

C:\temp>"c:\Program Files\ClayUtils\FILEDATA.EXE" test.txt
"FILENAME","FULLPATH","DATESTAMP","TIMESTAMP","SIZE","BITS","INTNAME","ORIGNAME","DESCRIPTION","FVER
","PRODUCT","PVER","OWNER","COPYRIGHT"
"TEST.TXT","C:\TEMP\TEST.TXT",01/10/2012,15:17:38,0,16,,,,,,,,

C:\temp>"c:\Program Files\ClayUtils\FILEINFO.EXE" test.txt

File Name, Path: TEST.TXT C:\TEMP\TEST.TXT
Date, Time, Size: 01/10/2012 15:17:38 0
Empty file, cannot process
Unknown type
No other information is available



Basically, I would like to make some metadata available for some files
directly in Explorer rather than having a filelist with extra columns
with the extra data.

If I have a filelist like
Filename,Author,Subject,Keywords
file1.txt,Author1,Subject1,Keywords1
file2.txt,Author2,Subject2,Keywords2
.
.
.

I would like to add this information
for /F "tokens=1,2,3,4 delims=," %%a in (filelist.txt) do (
SetProperties author=%%b subject=%%c keyword=%%d %%a
)

When the data has been added I would like to be able to see it from the
detailed view in Explorer and from the command line.



foxidrive

unread,
Jan 10, 2012, 10:03:44 AM1/10/12
to
On 11/01/2012 01:39, Martin Heller wrote:
> foxidrive wrote, on 10-01-2012 14:36:
>> You can mostly use a for /f in do command and use the short filename with the utility and redirect it all into a file.
>>
>> The %%~snx is buggy but tell us what you need to do and maybe something will work.
>
>
> I cannot get it to work properly:
>
> I have a txt file i c:\temp\test.txt
>
> If I add the properties "Title=Foo" and "Author=Bar" from the Explorer
> Properties Menu, then I can see these properties if I add them to the
> detailed view in Explorer.
>
> However, if I try filedata.exe or fileinfo.exe from a Command Prompt I
> cannot see this information:
>
> C:\temp>"c:\Program Files\ClayUtils\FILEDATA.EXE" test.txt
> "FILENAME","FULLPATH","DATESTAMP","TIMESTAMP","SIZE","BITS","INTNAME","ORIGNAME","DESCRIPTION","FVER
> ","PRODUCT","PVER","OWNER","COPYRIGHT"
> "TEST.TXT","C:\TEMP\TEST.TXT",01/10/2012,15:17:38,0,16,,,,,,,,
>
> C:\temp>"c:\Program Files\ClayUtils\FILEINFO.EXE" test.txt
>
> File Name, Path: TEST.TXT C:\TEMP\TEST.TXT
> Date, Time, Size: 01/10/2012 15:17:38 0

It looks like that file was zero bytes at that stage.

> Empty file, cannot process
> Unknown type
> No other information is available
>
>
>
> Basically, I would like to make some metadata available for some files
> directly in Explorer rather than having a filelist with extra columns
> with the extra data.
>
> If I have a filelist like
> Filename,Author,Subject,Keywords
> file1.txt,Author1,Subject1,Keywords1
> file2.txt,Author2,Subject2,Keywords2
> .
> .
> .
>
> I would like to add this information
> for /F "tokens=1,2,3,4 delims=," %%a in (filelist.txt) do (
> SetProperties author=%%b subject=%%c keyword=%%d %%a
> )
>
> When the data has been added I would like to be able to see it from the
> detailed view in Explorer and from the command line.

Someone else may know some tool or technique. Good luck.




--
Regards,
Mic

Martin Heller

unread,
Jan 10, 2012, 10:32:22 AM1/10/12
to
foxidrive wrote, on 10-01-2012 16:03:
> It looks like that file was zero bytes at that stage.

There was nothing in the file. But I get the same if I add some contents:

C:\temp>echo foo>>test.txt

C:\temp>"c:\Program Files\ClayUtils\FILEINFO.EXE" test.txt

File Name, Path: TEST.TXT C:\TEMP\TEST.TXT
Date, Time, Size: 01/10/2012 16:29:18 5 Unknown type
No other information is available


C:\temp>"c:\Program Files\ClayUtils\FILEDATA.EXE" test.txt
"FILENAME","FULLPATH","DATESTAMP","TIMESTAMP","SIZE","BITS","INTNAME","ORIGNAME","DESCRIPTION","FVER
","PRODUCT","PVER","OWNER","COPYRIGHT"
"TEST.TXT","C:\TEMP\TEST.TXT",01/10/2012,16:29:18,5,16,,,,,,,,

The Author and Title properties are still visible in Explorer.

Tom Lavedas

unread,
Jan 10, 2012, 10:40:51 AM1/10/12
to
On Jan 10, 8:27 am, Martin Heller <mr_hel...@yahoo.dk> wrote:
> foxidrive wrote, on 10-01-2012 13:52:
>
> > This might help - doesn't seem to understand long filenames so use the 8.3 name or wildcards
>
> > There is filedata.exe too and you might find updated versions, or look around for another utility.
>
> Thanks. It helped a bit but I do have lots of files with long filenames
> where I would like to access the properties.
>
> I found this
> <http://msdn.microsoft.com/en-us/library/windows/desktop/bb762231%28v=...>
>
>         SHObjectProperties function:
>         Invokes the Properties context menu command on a Shell object.
>
> However,
>
>         rundll32.exe shell32.dll,SHObjectProperties,<path to file>
>
> gives no output. How do I invoke SHObjectProperties correctly from the
> command line (if possible)?

I don't know how to use the rundll to do that, but the
Shell.Application object can be accessed easily in WScript. I built a
little example as a hybrid VBScript/batch file ...

@if .%3==. echo Syntax: %0 Pathspec filename index&exit /b 1
@(echo with CreateObject("Shell.Application"^).Namespace("%~1"^)
echo wsh.echo "%~2", .GetDetailsOf(.Items,%3^)^&":", _
echo .GetDetailsOf(.Parsename("%~2"^), %3^): end with
) > %temp%.\script.vbs
@cscript //nologo %temp%.\script.vbs
@del %temp%.\script.vbs

Asshown in the first line, it takes three command line arguments. The
tricky part is determining what index to supply, because it is OS
dependent. For example, the indexes for the properties are as
follows:

0 Name
1 Size
2 Type
3 Date Modified
4 Date Created
5 Date Accessed
6 Attributes
7 Status
8 Owner
9 Author
10 Title
11 Subject
12 Category
13 Pages
14 Comments
15 Copyright
16 Artist
17 Album Title
18 Year
19 Track Number
20 Genre
21 Duration
22 Bit Rate
23 Protected
24 Camera Model
25 Date Picture Taken
26 Dimensions
27
28
29 Episode Name
30 Program Description
31
32 Audio sample size
33 Audio sample rate
34 Channels
35 Company
36 Description
37 File Version
38 Product Name
39 Product Version
40 Keywords

But in Win7 there are 286 properties, most of which do not match the
indexes shown above. For example, here are the first 40 from Win7 ...

0 Name
1 Size
2 Item type
3 Date modified
4 Date created
5 Date accessed
6 Attributes
7 Offline status
8 Offline availability
9 Perceived type
10 Owner
11 Kind
12 Date taken
13 Contributing artists
14 Album
15 Year
16 Genre
17 Conductors
18 Tags
19 Rating
20 Authors
21 Title
22 Subject
23 Categories
24 Comments
25 Copyright
26 #
27 Length
28 Bit rate
29 Protected
30 Camera model
31 Dimensions
32 Camera maker
33 Company
34 File description
35 Program name
36 Duration
37 Is online
38 Is recurring
39 Location
40 Optional attendee addresses

To see all of the supported headers for this approach in Win 7 try
this procedure ...

@(echo with CreateObject("Shell.Application"^).Namespace("%CD%"^)
echo wsh.echo wsh.arguments(0^), _
echo .GetDetailsOf(.Items,wsh.arguments(0^)^)
echo end with) > %temp%.\script.vbs
@for /l %%N in (1,1,286) do @cscript //nologo %temp%.\script.vbs %%N
@del %temp%.\script.vbs

I noted that some obvious properties are supported in XP that are not
in Win 7, most notable is the Keywords item (missing in Win 7
implementation of the GetDetailsOf method).

Oh, that's weird - I just did a little experiment and found that the
name of Keywords (index 40 pre-W7/Vista?) has changed to Tags (index
18 in W7). So, it's even mor complicated to figure out the mapping
between the two OSs, ugh.

Well, HTH,
_________________________________
Tom Lavedas

foxidrive

unread,
Jan 10, 2012, 11:43:46 AM1/10/12
to
I did echo foo>>test.txt and the summary has blank entries. What do you get?


--
Regards,
Mic

Martin Heller

unread,
Jan 11, 2012, 2:47:07 AM1/11/12
to
foxidrive wrote, on 10-01-2012 17:43:
> I did echo foo>>test.txt and the summary has blank entries. What do you get?

It has blank entries if test.txt does not exist before echoing foo into
it. However, if I fill in the summary entries in Explorer and do
echo foo>>test.txt
then the entries remain and I kan read them in the Properties menu from
Explorer. FILEINFO.EXE and FILEDATA.EXE does not pick them up.


Martin Heller

unread,
Jan 11, 2012, 3:23:51 AM1/11/12
to
Tom Lavedas wrote, on 10-01-2012 16:40:
> I don't know how to use the rundll to do that, but the
> Shell.Application object can be accessed easily in WScript. I built a
> little example as a hybrid VBScript/batch file ...
>
> @if .%3==. echo Syntax: %0 Pathspec filename index&exit /b 1
> @(echo with CreateObject("Shell.Application"^).Namespace("%~1"^)
> echo wsh.echo "%~2", .GetDetailsOf(.Items,%3^)^&":", _
> echo .GetDetailsOf(.Parsename("%~2"^), %3^): end with
> )> %temp%.\script.vbs
> @cscript //nologo %temp%.\script.vbs
> @del %temp%.\script.vbs
>
> Asshown in the first line, it takes three command line arguments.

Thanks. This works.

C:\tmp>getinfo.bat "%CD%" test.txt 11
fatal: Not a git repository (or any of the parent directories): .git
test.txt Subject: Bar

For some reason the Shell.Application object interacts with git.

Martin Heller

unread,
Jan 11, 2012, 3:42:21 AM1/11/12
to
Tom Lavedas wrote, on 10-01-2012 16:40:
> I don't know how to use the rundll to do that, but the
> Shell.Application object can be accessed easily in WScript. I built a
> little example as a hybrid VBScript/batch file ...
>
> @if .%3==. echo Syntax: %0 Pathspec filename index&exit /b 1
> @(echo with CreateObject("Shell.Application"^).Namespace("%~1"^)
> echo wsh.echo "%~2", .GetDetailsOf(.Items,%3^)^&":", _
> echo .GetDetailsOf(.Parsename("%~2"^), %3^): end with
> )> %temp%.\script.vbs
> @cscript //nologo %temp%.\script.vbs
> @del %temp%.\script.vbs

A follow-up question: I did the naive search for a "SetDetailsOf"
method, but to no avail. Does VBScript provide a method for setting the
file properties?


Tom Lavedas

unread,
Jan 11, 2012, 2:33:52 PM1/11/12
to
Nope, not native to any object accessible from VBScript and common to
the bare Windows install. Not that I know about, anyway. AFAIK, it
requires a third party library or the use of the automation interface
to one of the MSOffice applications, like Word.Application.
____________________________
Tom Lavedas

Dr J R Stockton

unread,
Jan 11, 2012, 5:12:44 PM1/11/12
to
In alt.msdos.batch.nt message <4f0c3ccf$0$285$1472...@news.sunsite.dk>,
Tue, 10 Jan 2012 14:27:35, Martin Heller <mr_h...@yahoo.dk> posted:

>Thanks. It helped a bit but I do have lots of files with long filenames
>where I would like to access the properties.

One can at the command line use WSH CScript with JScript or WScript code
to locate a file by long name and send to standard-output its short
name.

The following demonstrates that the possibility exists.

Give prompt>SEEK . hlongfilename.html e AJ
Get LONGFI~1.HTM

Use prompt>SEEK . hlongfi~1.htm e @s AI
to reverse.

It will however, find all files whose long name *includes*
longfilename.html - if there is not yet a way to be fully selective I
need to add one.

--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05.
Website <http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc. : <http://www.merlyn.demon.co.uk/programs/> - see in 00index.htm
Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.

Martin Heller

unread,
Jan 12, 2012, 3:50:51 AM1/12/12
to
Tom Lavedas wrote, on 11-01-2012 20:33:
> Nope, not native to any object accessible from VBScript and common to
> the bare Windows install. Not that I know about, anyway. AFAIK, it
> requires a third party library or the use of the automation interface
> to one of the MSOffice applications, like Word.Application.

It appears that I can use dsofile.dll from
<http://support.microsoft.com/kb/224351>

The following works in a VBScript and sets the Title and Comments field
of my test dosument:

Set oFile = CreateObject("DSOFile.OleDocumentProperties")
oFile.Open("c:\tmp\test.txt")
oFile.SummaryProperties.Comments = "Test Comment"
oFile.SummaryProperties.Title = "Test Title"
oFile.Save
oFile.Close

Tom Lavedas

unread,
Jan 12, 2012, 8:55:24 AM1/12/12
to
Yes, I seem to remember that, but as I said - it's not native, though
it is a free download. I seem to recall some people reporting that
the MS implementation causes problems with some properties related to
picture files. I don't have personal experience, so I can't be sure.
_______________________________
Tom Lavedas

tre...@gmx.de

unread,
Dec 21, 2017, 10:44:35 AM12/21/17
to
Hello,

i using following vbs script:
------------------------------------------------------------------------------
Set loFile = CreateObject("DSOFile.OleDocumentProperties")

loFile.Open("F:\Software\PC-Live.Exe")

loFile.SummaryProperties.Title = "Ask / Answer"
loFile.SummaryProperties.Subject = "PC-Live"
loFile.SummaryProperties.Category = "PC-Tools"
loFile.SummaryProperties.Keywords = "My keyword"
loFile.SummaryProperties.Comments = "Diese Datei ist Teil der Installation des Programmes PC-Live."

loFile.SummaryProperties.Author = "www.PC-Tools.de In...@PC-Tools.de"

loFile.Save
loFile.Close
------------------------------------------------------------------------------

I would like to set the following properties:
loFile.SummaryProperties.Source (Quelle)
loFile.SummaryProperties.Version

But these 2 properties can not be set. I get an error message that these properties does not exists. How can i set these 2 properties?


Best regards

JJ

unread,
Dec 21, 2017, 1:20:43 PM12/21/17
to
On Thu, 21 Dec 2017 07:44:33 -0800 (PST), tre...@gmx.de wrote:
>
> I would like to set the following properties:
> loFile.SummaryProperties.Source (Quelle)
> loFile.SummaryProperties.Version
>
> But these 2 properties can not be set. I get an error message that these
> properties does not exists. How can i set these 2 properties?
>
> Best regards

`Version` property is read-only.

`Source` property is likely a custom property because DSO doesn't have that
property for its object interface.
0 new messages