|
Answer» Okay I'm using VB script to try to print information for all the files in directory, I'm able to get the file name and the date created, however I cant SEEM to find any information on how to get the comments of the file.
rightClick on file>properties>summary>comments
This is the code I have so far. Thanks in advance. If I happen to stumble upon the answer I'll make sure to post it here.
Code: [Select]dim fsoFolder, outputFolder, NBoutputFolder, files Set fsoFolder = CreateObject("Scripting.FileSystemObject")
If Not fsoFolder.FolderExists(OutputPath) Then newfolder = fsoFolder.CreateFolder (OutputPath) End If
Set outputfolder = fsoFolder.getFolder(OutputPath & "held\") set files = outputFolder.Files
dim fileName, dateUpdated, descrip if(not (isNull(files)) ) then 'for loop to generate all the entrys in folder for each objFile in files response.write("==========================="& "<BR>") response.write("<U>FileName:</U>   "& objFile.Name & "<br>") response.write("<u>Date Createrd</U>   "& objFile.DateCreated & "<BR>") 'This following line GIVE an error:Object doesn't support this property or method: 'Comments' 'response.write("AUTHOR Comments:<BR>   "& objFile.Comments & "<BR>") next
else response.write("There are no published exe in Folder") end if
Also I would like to be able to set the comments for a file from the script.I don't have the expertise to answer questions about VB script. I'm just wondering why you posted your question in the Web Design section. Does this really pertain to a website? Looks to me like it's more of a programming question and should have been posted in the Programming forum.Well I'm having to display the list of files on a webpage that will resemble something like a library. The user will add a comment to a file they publish and this comment should be added to the file and then be available to be viewed by other users. I'm pretty sure you're looking for the extended properties of a file.
This little snippet lists out all the properties available:
Code: [Select]'List Of Attributes
strFolder = "c:\documents and settings\all users\documents\my pictures\sample pictures" strFile = "blue hills.JPG"
Set objShellApp = CreateObject("Shell.Application") Set objFolder = objShellApp.NameSpace(strFolder) Set objFolderItem = objFolder.ParseName(strFile)
Dim arrHeaders(39) For i = 0 To Ubound(arrHeaders) arrHeaders(i) = objFolder.GetDetailsOf(objFolder.Items, i) Next
For i = 0 To Ubound(arrHeaders) Wscript.Echo i & vbtab & arrHeaders(i) _ & ": " & objFolder.GetDetailsOf(objFolderItem, i) Next
Once you KNOW the index of the property, you can directly access them like this:
Code: [Select]strFolder = "c:\documents and settings\all users\documents\my pictures\sample pictures" strFile = "blue hills.JPG"
' Specific Attribute
Set objShellApp = CreateObject("Shell.Application") Set objFolder = objShellApp.NameSpace(strFolder) Set objFolderItem = objFolder.ParseName(strFile)
strName = objFolder.GetDetailsOf(objFolderItem, 0) WScript.Echo "Name: " & strName
strDimension = objFolder.GetDetailsOf(objFolderItem, 26) WScript.Echo "Dimension: " & strDimension
The examples are for a jpg file. Files will only have extended properties which make logical sense. For instance, pictures will not have an album title property.
Hope this helps.
PS. Attributes are zero based. Thanks Sidewinder excatly what I was looking for to obtain the file attributes.
You wouldn't happen to know how to go about changing these attributes from a script? Attributes accessed through the Shell.Application are read-only. Normally I try not to have posters download stuff, but in this case you'll need to download and install the DSOFile COM component.
With DSO the properties are still read-only except for Author, Category, Comments, Company, Keywords, LastEditedBy, Manager, Subject, and Title. With DSO you can also create your own custom properties.
Code: [Select]strFile = ""c:\documents and settings\all users\documents\my pictures\sample pictures\blue hills.JPG"
Set dso = CreateObject("DSOFile.oleDocumentProperties") dso.Open(strFile) dso.SummaryProperties.Comments = "This Is A Test" dso.Save
The example shows how to change the Comments property to This Is A Test.
Good luck.
|