Discussion:
How to access file object properties (title, subject, author, category, keywords, comments, the URL to which a shortcut file links, etc.
(too old to reply)
Marc B. Hankin
2005-02-19 05:51:18 UTC
Permalink
Does anyone know where I can find info about how to use vbscript
to put date into (or suck data out of) the following
properties of a file:
1. title, subject, author, category, keywords, comments?
2. the url to which a shortcut file links?

Thanks to whoever answers,

Marceepoo
McKirahan
2005-02-19 11:11:07 UTC
Permalink
Post by Marc B. Hankin
Does anyone know where I can find info about how to use vbscript
to put date into (or suck data out of) the following
1. title, subject, author, category, keywords, comments?
2. the url to which a shortcut file links?
Thanks to whoever answers,
Marceepoo
Your Subject's too long -- didn't read it.

Are you talking about an HTML file or any file?

Be a little more specific.
Marc B. Hankin
2005-02-19 17:35:32 UTC
Permalink
Dear Ms/Mr. McKirahan:

1. Shortcut files: I have a directory on my local drive containing
shortcut files. I am trying to create a script that will send to an array
both each shortcut file's fullname (name + path), and each shortcut file's
respective url target (i.e., the website on the internet) to which each
respective shortcut file points. If you right click on a shortcut file, and
then click Properties, and then select the Web Document Tab, you see a
Dialog box containing a two properties/fields (URL, and Shortcut Key) plus
some other stuff not relevant here.
I can't figure out how to get the script to access the data in
shortcut files' URL field, so that I may:
A. Echo the URL field. (Once I learn how to echo it, I'll know how
to assign the data to an array); and how to...
B. Paste new replacement data into the field, to replace the
existing URL target, if any.
2. Vbscript files: If you right click on a vbscript file, and then click
Properties, and then click the Summary Tab, you see a Dialog box containing
a set of six properties/fields (Title, subject, author, category, keywords,
comments).
I can't figure out how to get the script to:
A. Echo the contents of those six properties/fields; and how to...
B. Paste data into those six properties/fields.
Also, thanks for the feedback about lengthy subject lines. I will be
careful to make them shorter.
Post by McKirahan
Post by Marc B. Hankin
Does anyone know where I can find info about how to use vbscript
to put date into (or suck data out of) the following
1. title, subject, author, category, keywords, comments?
2. the url to which a shortcut file links?
Thanks to whoever answers,
Marceepoo
Your Subject's too long -- didn't read it.
Are you talking about an HTML file or any file?
Be a little more specific.
McKirahan
2005-02-19 21:22:44 UTC
Permalink
Post by Marc B. Hankin
1. Shortcut files: I have a directory on my local drive containing
shortcut files. I am trying to create a script that will send to an array
both each shortcut file's fullname (name + path), and each shortcut file's
respective url target (i.e., the website on the internet) to which each
respective shortcut file points. If you right click on a shortcut file, and
then click Properties, and then select the Web Document Tab, you see a
Dialog box containing a two properties/fields (URL, and Shortcut Key) plus
some other stuff not relevant here.
I can't figure out how to get the script to access the data in
A. Echo the URL field. (Once I learn how to echo it, I'll know how
to assign the data to an array); and how to...
B. Paste new replacement data into the field, to replace the
existing URL target, if any.
2. Vbscript files: If you right click on a vbscript file, and then click
Properties, and then click the Summary Tab, you see a Dialog box containing
a set of six properties/fields (Title, subject, author, category, keywords,
comments).
A. Echo the contents of those six properties/fields; and how to...
B. Paste data into those six properties/fields.
Also, thanks for the feedback about lengthy subject lines. I will be
careful to make them shorter.
Post by McKirahan
Post by Marc B. Hankin
Does anyone know where I can find info about how to use vbscript
to put date into (or suck data out of) the following
1. title, subject, author, category, keywords, comments?
2. the url to which a shortcut file links?
Thanks to whoever answers,
Marceepoo
Your Subject's too long -- didn't read it.
Are you talking about an HTML file or any file?
Be a little more specific.
Will this help?
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/ht
ml/wsconmanagingshortcuts.asp

(Please don't top post.)
Marc B. Hankin
2005-02-19 22:08:51 UTC
Permalink
Post by Marc B. Hankin
Post by Marc B. Hankin
1. Shortcut files: I have a directory on my local drive containing
shortcut files. I am trying to create a script that will send to an array
both each shortcut file's fullname (name + path), and each shortcut file's
respective url target (i.e., the website on the internet) to which each
respective shortcut file points. If you right click on a shortcut file,
and
Post by Marc B. Hankin
then click Properties, and then select the Web Document Tab, you see a
Dialog box containing a two properties/fields (URL, and Shortcut Key) plus
some other stuff not relevant here.
I can't figure out how to get the script to access the data in
A. Echo the URL field. (Once I learn how to echo it, I'll know
how
Post by Marc B. Hankin
to assign the data to an array); and how to...
B. Paste new replacement data into the field, to replace the
existing URL target, if any.
2. Vbscript files: If you right click on a vbscript file, and then click
Properties, and then click the Summary Tab, you see a Dialog box
containing
Post by Marc B. Hankin
a set of six properties/fields (Title, subject, author, category,
keywords,
Post by Marc B. Hankin
comments).
A. Echo the contents of those six properties/fields; and how to...
B. Paste data into those six properties/fields.
Also, thanks for the feedback about lengthy subject lines. I will be
careful to make them shorter.
Post by McKirahan
Post by Marc B. Hankin
Does anyone know where I can find info about how to use vbscript
to put date into (or suck data out of) the following
1. title, subject, author, category, keywords, comments?
2. the url to which a shortcut file links?
Thanks to whoever answers,
Marceepoo
Your Subject's too long -- didn't read it.
Are you talking about an HTML file or any file?
Be a little more specific.
Will this help?
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/ht
ml/wsconmanagingshortcuts.asp
(Please don't top post.)
Thanks. It helps a lot with the Shortcut files.
Any ideas about Question #2 (reproduced below, for convenience, since I
erred earlier by top posting)?

2. Vbscript files: If you right click on a vbscript file, and then click
Properties, and then click the Summary Tab, you see a Dialog box containing
a set of six properties/fields (Title, subject, author, category, keywords,
comments).
I can't figure out how to get the script to:
A. Echo the contents of those six properties/fields; and how to...
B. Paste data into those six properties/fields.

Thanks again, Marc
Michael Harris (MVP)
2005-02-20 02:41:25 UTC
Permalink
Post by Marc B. Hankin
Any ideas about Question #2 (reproduced below, for convenience, since
I erred earlier by top posting)?
2. Vbscript files: If you right click on a vbscript file, and then
click Properties, and then click the Summary Tab, you see a Dialog
box containing a set of six properties/fields (Title, subject,
author, category, keywords, comments).
A. Echo the contents of those six properties/fields; and how
to... B. Paste data into those six properties/fields.
ExtendedProperty Method (ShellFolderItem) (Windows Explorer and Controls)
http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/reference/objects/shellfolderitem/extendedproperty.asp?frame=true

set shellApp = createobject("shell.application")

set oItem = shellApp.Namespace("c:\").parsename("test.txt")

arPropNames = array(_
"Title",_
"Subject",_
"Author",_
"Keywords",_
"Comments",_
"Template",_
"Last Saved",_
"Revision Number",_
"Total Editing",_
"Last Printed",_
"Create Time/Date",_
"Last Saved Time/Date",_
"Number of Pages",_
"Number of Words",_
"Number of Characters",_
"Thumbnail",_
"Name of Creating Application",_
"Security"_
)

for each propname in arPropNames
s = s & propname & "=" _
& oItem.ExtendedProperty(propname) & vbcrlf
next

msgbox s
--
Michael Harris
Microsoft MVP Scripting
http://maps.google.com/maps?q=Sammamish%20WA%20US
Roland Hall
2005-02-20 10:37:56 UTC
Permalink
"Michael Harris (MVP)" <mikhar at mvps dot org> wrote in message news:%***@tk2msftngp13.phx.gbl...
:> Any ideas about Question #2 (reproduced below, for convenience, since
: > I erred earlier by top posting)?
: >
: > 2. Vbscript files: If you right click on a vbscript file, and then
: > click Properties, and then click the Summary Tab, you see a Dialog
: > box containing a set of six properties/fields (Title, subject,
: > author, category, keywords, comments).
: > I can't figure out how to get the script to:
: > A. Echo the contents of those six properties/fields; and how
: > to... B. Paste data into those six properties/fields.
: >
:
: ExtendedProperty Method (ShellFolderItem) (Windows Explorer and Controls)
:
http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/reference/objects/shellfolderitem/extendedproperty.asp?frame=true
:
: set shellApp = createobject("shell.application")
:
: set oItem = shellApp.Namespace("c:\").parsename("test.txt")
:
: arPropNames = array(_
: "Title",_
: "Subject",_
: "Author",_
: "Keywords",_
: "Comments",_
: "Template",_
: "Last Saved",_
: "Revision Number",_
: "Total Editing",_
: "Last Printed",_
: "Create Time/Date",_
: "Last Saved Time/Date",_
: "Number of Pages",_
: "Number of Words",_
: "Number of Characters",_
: "Thumbnail",_
: "Name of Creating Application",_
: "Security"_
: )
:
: for each propname in arPropNames
: s = s & propname & "=" _
: & oItem.ExtendedProperty(propname) & vbcrlf
: next
:
: msgbox s

parsename? It appears parsename is different for TSQL, DTS and Win32/COM.
How confusing.
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Vercellone
2005-02-24 20:13:07 UTC
Permalink
I was looking to update a batch of bogus Word Document Author property
values based on owner values when I came across this thread. I found a
solution that I thought you might find useful:

http://www.microsoft.com/technet/scriptcenter/resources/qanda/oct04/hey1
001.mspx

In case the above link dies before this thread does, the relevant
content follows:

-------- BEGIN PASTE
Q. How Can I Write to the Comments Field of a Document?

-- EF

A. Hey, Scripting Guy! Can I add text to the Comments field of a file
using a script?

Hey, EF. For those of you who aren�t sure what EF is referring to,
right-click a document in Windows Explorer and then click Properties. In
the dialog box that appears, click on the Summary tab. See the text box
labeled Comments? That�s the field EF would like to be able to populate
using a script.

So is that possible? As a matter of fact it is, provided you go to the
Downloads Center on Microsoft.com
(http://www.microsoft.com/downloads/search.aspx?displaylang=en) and
download Dsofile. Dsofile installs a new COM object that allows you to
both read from and write to the summary information fields for a
document. For example, here�s a script that adds the clever comment
�This is a comment� to the Comments field for a document:

Set objPropertyReader = CreateObject("DSOleFile.PropertyReader")
Set objDocument = objPropertyReader.GetDocumentProperties _
("C:\Scripts\Test.doc")
objDocument.Comments = "This is a comment."

Pretty slick, huh? Summary information fields you can change using a
script include: Author; Category; Comments; Company; Keywords;
LastEditedBy; Manager; Subject; and Title.

And, of course, you can read the summary information fields as well:

Set objPropertyReader = CreateObject("DSOleFile.PropertyReader")
Set objDocument = objPropertyReader.GetDocumentProperties _
("C:\Scripts\Test.doc")
Wscript.Echo "App name: " & objDocument.AppName
Wscript.Echo "Author: " & objDocument.Author
Wscript.Echo "Byte count: " & objDocument.ByteCount
Wscript.Echo "Category: " & objDocument.Category
Wscript.Echo "Character count: " & objDocument.CharacterCount
Wscript.Echo "Character count with spaces: " &
objDocument.CharacterCountWithSpaces
Wscript.Echo "CLSID: " & objDocument.CLSID
Wscript.Echo "Comments: " & objDocument.Comments
Wscript.Echo "Company: " & objDocument.Company
Set colCustomProperties = objDocument.CustomProperties
For Each strProperty in colCustomProperties
Wscript.Echo vbTab & strProperty.Name & ": " & strProperty.Value
Next
Wscript.Echo "Date created: " & objDocument.DateCreated
Wscript.Echo "Date last printed: " & objDocument.DateLastPrinted
Wscript.Echo "Date last saved: " & objDocument.DateLastSaved
Wscript.Echo "Has macros: " & objDocument.HasMacros
Wscript.Echo "Hidden slides: " & objDocument.HiddenSlides
Wscript.Echo "Icon: " & objDocument.Icon
Wscript.Echo "Is read only: " & objDocument.IsReadOnly
Wscript.Echo "Keywords" & objDocument.Keywords
Wscript.Echo "Last edited by: " & objDocument.LastEditedBy
Wscript.Echo "Line count: " & objDocument.LineCount
Wscript.Echo "Location: " & objDocument.Location
Wscript.Echo "Manager: " & objDocument.Manager
Wscript.Echo "Multimedia clips: " & objDocument.MultimediaClips
Wscript.Echo "Name: " & objDocument.Name
Wscript.Echo "Page count: " & objDocument.PageCount
Wscript.Echo "Paragraph count: " & objDocument.ParagraphCount
Wscript.Echo "Presentation format: " & objDocument.PresentationFormat
Wscript.Echo "Presentation notes: " & objDocument.PresentationNotes
Wscript.Echo "ProgID: " & objDocument.ProgID
Wscript.Echo "Revision number: " & objDocument.RevisionNumber
Wscript.Echo "Slide count: " & objDocument.SlideCount
Wscript.Echo "Subject: " & objDocument.Subject
Wscript.Echo "Template: " & objDocument.Template
Wscript.Echo "Thumbnail: " & objDocument.Thumbnail
Wscript.Echo "Title: " & objDocument.Title
Wscript.Echo "Version: " & objDocument.Version
Wscript.Echo "Word count: " & objDocument.WordCount

Before you ask, we don�t know of any method built into the operating
system that enables you to modify the summary information fields; you�ll
have to download Dsofile to do that. It is possible, however, to read at
least some of this information using the Windows Shell object. For
details, check out this section of the Microsoft Windows 2000 Scripting
Guide.
For More Information

Check out the Hey, Scripting Guy! - Archive
-------- END PASTE

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Vercellone
2005-02-28 23:40:08 UTC
Permalink
The code snippet provided in my previously quoted solution did not
produce the expected results. Following is a working code sample I
created to meet my own needs:

-------- BEGIN PASTE
Option Explicit

Dim strPath
Dim strOwner

Dim objFile
Dim objFileProperties
Dim objFileSystemObject
Dim objFolder
Dim objShellApp
Dim objShellItem
Dim objSummaryProperties

' set your desired path here - Note: this code does NOT traverse
subfolders
strPath = "C:\foo"

' Encountered errors for some (read-only?) files - Remove next line to
debug, if desired
on error resume next

' DSO Writable Properties Object
Set objFileProperties = CreateObject("DSOFile.OleDocumentProperties")

' Read-only Extended Shell Properties / FileSystem Objects
Set objFileSystemObject = CreateObject("Scripting.FileSystemObject")
set objShellApp = createobject("shell.application")

if objFileSystemObject.FolderExists(strPath) then
' Retrieve folder contents
Set objFolder = objFileSystemObject.GetFolder(strPath)

' Loop through files in folder
For Each objFile in objFolder.Files
' DSO File Open + retrieve summary properties (search microsoft about
manipulating custom properties w/DSOFile)
objFileProperties.Open objFile.path
Set objSummaryProperties = objFileProperties.SummaryProperties

' Retrieve Read-Only Extended Shell Object Property: "Owner"
set objShellItem =
objShellApp.Namespace(strPath).parsename(objFile.name)
strOwner = objShellItem.ExtendedProperty("Owner")
set objShellItem = nothing

wscript.echo objFile.name & " Author: " & objSummaryProperties.Author
& " Owner: " & strOwner


' Enable/alter the following lines to modify the property or
properties of your choosing
' Set value of Author property (refer to MS docs for other properties
available)
' objSummaryProperties.Author = strOwner

' Save changes
' objFileProperties.Save

objFileProperties.Close
Set objSummaryProperties = nothing
Next
wscript.echo "Done!"
else
wscript.echo "Path not found: " & strPath
End If

' Cleanup
Set objFile = nothing
Set objFileProperties = nothing
Set objFolder = nothing
Set objFileSystemObject = nothing
set objShellApp = nothing
-------- END PASTE

Just save into a .vbs file and modify to suit your needs. Hope this
helps.

-Vercellone


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
jmedero999
2006-05-26 16:23:50 UTC
Permalink
First off, the coding worked beautifully. I was able to get this codin
to modify any existing SummaryProperties
property (in particular the comments property).
I was even able to create new custom properties. But the problem
encountered as that I couldn't enter a new comment if the file ha
never had a comment or any SummaryProperties entered.
It appears that I only can do update on the summary properties if th
file has one of the summary properties set. It doesn't matter whic
property is set, but one of them MUST be set otherwise it doesn'
take.
I've been able to repeatedly create the scenario.

I need to be able to enter comments for all files in specifi
directories, so that if the files are moved elsewhere, the origina
location and other details about the file when it was created will sta
with the file.
I can't place this information directly in the file as the files can b
of different types (excel, brio cubes, word documents, pdf, tex
etc...)

Any suggestions or ideas would be appreciated!!!
*The code snippet provided in my previously quoted solution did not
produce the expected results. Following is a working code sample I
-------- BEGIN PASTE
Option Explicit
Dim strPath
Dim strOwner
Dim objFile
Dim objFileProperties
Dim objFileSystemObject
Dim objFolder
Dim objShellApp
Dim objShellItem
Dim objSummaryProperties
' set your desired path here - Note: this code does NOT traverse
subfolders
strPath = "C:\foo"
' Encountered errors for some (read-only?) files - Remove next lin
to
debug, if desired
on error resume next
' DSO Writable Properties Object
Set objFileProperties
CreateObject("DSOFile.OleDocumentProperties")
' Read-only Extended Shell Properties / FileSystem Objects
Set objFileSystemObject = CreateObject("Scripting.FileSystemObject")
set objShellApp = createobject("shell.application")
if objFileSystemObject.FolderExists(strPath) then
' Retrieve folder contents
Set objFolder = objFileSystemObject.GetFolder(strPath)
' Loop through files in folder
For Each objFile in objFolder.Files
' DSO File Open + retrieve summary properties (search microsof
about
manipulating custom properties w/DSOFile)
objFileProperties.Open objFile.path
Set objSummaryProperties = objFileProperties.SummaryProperties
' Retrieve Read-Only Extended Shell Object Property: "Owner"
set objShellItem =
objShellApp.Namespace(strPath).parsename(objFile.name)
strOwner = objShellItem.ExtendedProperty("Owner")
set objShellItem = nothing
wscript.echo objFile.name & " Author: "
objSummaryProperties.Author
& " Owner: " & strOwner
' Enable/alter the following lines to modify the property or
properties of your choosing
' Set value of Author property (refer to MS docs for othe
properties
available)
' objSummaryProperties.Author = strOwner
' Save changes
' objFileProperties.Save
objFileProperties.Close
Set objSummaryProperties = nothing
Next
wscript.echo "Done!"
else
wscript.echo "Path not found: " & strPath
End If
' Cleanup
Set objFile = nothing
Set objFileProperties = nothing
Set objFolder = nothing
Set objFileSystemObject = nothing
set objShellApp = nothing
-------- END PASTE
Just save into a .vbs file and modify to suit your needs. Hope this
helps.
-Vercellone
*** Sent via Developersdex [url]http://www.developersdex.com[/url
***
Don't just participate in USENET...get rewarded for it!
-
jmedero99
-----------------------------------------------------------------------
Posted via http://www.codecomments.co
-----------------------------------------------------------------------
bob martin
2005-03-18 16:21:56 UTC
Permalink
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Loading...