felanor Posted May 23, 2008 Posted May 23, 2008 Hi Everyone, I noticed that if you right click a file and choose properties, there is a tab called summary. In there you can give the file several descriptions, including a title, subject, author, category, keywords, and comments. Is there any way to set these fields with AutoIt? I've tried searching the forums and haven't come up with anything yet. Thanks ~Felanor Check Out My ScriptsFile Property Management - Adjust a file's title, author, subject, etc.
enaiman Posted May 23, 2008 Posted May 23, 2008 I'm sure the AutoIt3Wrapper options might help you. Have a play with them.http://www.autoitscript.com/autoit3/scite/...oIt3Wrapper.htm SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
felanor Posted May 23, 2008 Author Posted May 23, 2008 I'm sure the AutoIt3Wrapper options might help you. Have a play with them.http://www.autoitscript.com/autoit3/scite/...oIt3Wrapper.htmThanks for the assistance, but that isn't exactly what I'm looking for. I'm creating a database file and I want to store the title for the database in the property of the file.~Felanor Check Out My ScriptsFile Property Management - Adjust a file's title, author, subject, etc.
felanor Posted May 24, 2008 Author Posted May 24, 2008 Any help would be greatly appreciated. ~Felanor Check Out My ScriptsFile Property Management - Adjust a file's title, author, subject, etc.
rover Posted May 24, 2008 Posted May 24, 2008 (edited) Search for "file properties" "extended properties" "metadata" on forum search for more posts on this well covered topicNote: some examples on the forum are for the older version of the Dsofile.dllMicrosoft TechNet column: Tales from the Script - March 2005: Dsofile: The Untold Storyhttp://www.microsoft.com/technet/scriptcen...les/sg0305.mspxDsofile.dll installer - latest versionhttp://support.microsoft.com/kb/224351Udf: Get Extended File Property - ExtProp.au3http://www.autoitscript.com/forum/index.php?showtopic=25859http://www.autoitscript.com/forum/index.php?showtopic=31614http://www.autoitscript.com/forum/index.php?showtopic=19032Edit: forgot this link to another metadata UDFUDF GetFileProperty, Return any property of a file by namehttp://www.autoitscript.com/forum/index.php?showtopic=34732basic example of Dsofile.dll usageinstaller registers DLLotherwise run regsvr32.exe Dsofile.dlltested on AutoIt EXEs' succesfully as well as text files, word docs, etc.Caveat: YMMVtry on a copy of your database fileexpandcollapse popup; constants for new properties type Global Const $msoPropertyTypeNumber = 1 Global Const $msoPropertyTypeBoolean = 2 Global Const $msoPropertyTypeDate = 3 Global Const $msoPropertyTypeString = 4 Global $g_eventerror = 0 ; to be checked to know if com error occurs. Must be reset after handling. $file = FileOpenDialog("Select a file to read/change file properties",@ScriptDir,"All (*.*)") If @error Then Exit If Not FileExists($file) Then Exit Global $oMyError = ObjEvent("AutoIt.Error", "ComErrorHandler"); Install a custom error handler $objFile = ObjCreate("DSOFile.OleDocumentProperties") If $g_eventerror Then Exit $g_eventerror = 0 If Not IsObj($objFile) Then Exit $objFile.Open($file) ; bind to the summary information metadata attached to the file. If $g_eventerror Then Exit $g_eventerror = 0 ;~ ; Remove properties ;~ $objProperty = $objFile.CustomProperties.Item("CustomItem") ;~ $objProperty.Remove ;~ $objFile.Save ; Create new property ; Add new property ;$objFile.CustomProperties.Add "CustomItem", $msoPropertyTypeString ;$objFile.Save ; Set new property value ;$objProperty = $objFile.CustomProperties.Item("CustomItem") ;$objProperty.Value = "CustomText" ;$objFile.Save ; Modify existing properties - Note: some wont allow writing to even if they exist in file ; more properties available - use DLL Export Viewer or OLE/COM Object Viewer 'oleview.exe' on dsofile.dll ; see also http://www.microsoft.com/technet/scriptcenter/resources/tales/sg0305.mspx for a list $objFile.SummaryProperties.Title = "Title" ; replace Title text here ;$objFile.SummaryProperties.Subject = "Subject" ;$objFile.SummaryProperties.Category = "Category" ;$objFile.SummaryProperties.Keywords = "Keywords" ;$objFile.SummaryProperties.Comments = "Comments" ;$objFile.SummaryProperties.Company = "Company" ;$objFile.SummaryProperties.Author = "Author" ;$objFile.SummaryProperties.RevisionNumber = "?" $objFile.Save ; save changes to file properties If $g_eventerror Then Exit $g_eventerror = 0 ; Retrieve custom properties values (if any) For $objProperty In $objFile.CustomProperties ConsoleWrite("+> " & $objProperty.Name & " : " & $objProperty.Value & @crlf) Next ; display a sampling of some properties of file $Title = $objFile.SummaryProperties.Title ConsoleWrite('-> $Title = ' & $Title & @crlf) $Subject = $objFile.SummaryProperties.Subject ConsoleWrite('-> $Subject = ' & $Subject & @crlf) $Category = $objFile.SummaryProperties.Category ConsoleWrite('-> $Category = ' & $Category & @crlf) $Keywords = $objFile.SummaryProperties.Keywords ConsoleWrite('-> $Keywords = ' & $Keywords & @crlf) $Comments = $objFile.SummaryProperties.Comments ConsoleWrite('-> $Comments = ' & $Comments & @crlf) $Company = $objFile.SummaryProperties.Company ConsoleWrite('-> $Company = ' & $Company & @crlf) $Author = $objFile.SummaryProperties.Author ConsoleWrite('-> $Author = ' & $Author & @crlf) $RevisionNumber = $objFile.SummaryProperties.RevisionNumber ConsoleWrite('-> $RevisionNumber = ' & $RevisionNumber & @crlf) $objFile.Close ; unbind from the summary information metadata attached to the file. Exit Func ComErrorHandler() ; optionally bypass message box, or use ConsoleWrite, Debugview or log errors to file Local $sHexNumber = Hex($oMyError.number,8) Local $sDesc = StringStripWS($oMyError.windescription, 2) Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $sHexNumber & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF) $g_eventerror = 1 ; something to check for when this function returns $oMyError.clear Endfunc Edited May 24, 2008 by rover I see fascists...
PsaltyDS Posted May 24, 2008 Posted May 24, 2008 Search for "file properties" "extended properties" "metadata" on forum search for more posts on this well covered topic Note: some examples on the forum are for the older version of the Dsofile.dll Microsoft TechNet column: Tales from the Script - March 2005: Dsofile: The Untold Story http://www.microsoft.com/technet/scriptcen...les/sg0305.mspx Dsofile.dll installer - latest version http://support.microsoft.com/kb/224351 Udf: Get Extended File Property - ExtProp.au3 http://www.autoitscript.com/forum/index.php?showtopic=25859 http://www.autoitscript.com/forum/index.php?showtopic=31614 http://www.autoitscript.com/forum/index.php?showtopic=19032 Edit: forgot this link to another metadata UDF UDF GetFileProperty, Return any property of a file by name http://www.autoitscript.com/forum/index.php?showtopic=34732 basic example of Dsofile.dll usage installer registers DLL otherwise run regsvr32.exe Dsofile.dll tested on AutoIt EXEs' succesfully as well as text files, word docs, etc. Caveat: YMMV try on a copy of your database file expandcollapse popup; constants for new properties type Global Const $msoPropertyTypeNumber = 1 Global Const $msoPropertyTypeBoolean = 2 Global Const $msoPropertyTypeDate = 3 Global Const $msoPropertyTypeString = 4 Global $g_eventerror = 0 ; to be checked to know if com error occurs. Must be reset after handling. $file = FileOpenDialog("Select a file to read/change file properties",@ScriptDir,"All (*.*)") If @error Then Exit If Not FileExists($file) Then Exit Global $oMyError = ObjEvent("AutoIt.Error", "ComErrorHandler"); Install a custom error handler $objFile = ObjCreate("DSOFile.OleDocumentProperties") If $g_eventerror Then Exit $g_eventerror = 0 If Not IsObj($objFile) Then Exit $objFile.Open($file) ; bind to the summary information metadata attached to the file. If $g_eventerror Then Exit $g_eventerror = 0 ;~ ; Remove properties ;~ $objProperty = $objFile.CustomProperties.Item("CustomItem") ;~ $objProperty.Remove ;~ $objFile.Save ; Create new property ; Add new property ;$objFile.CustomProperties.Add "CustomItem", $msoPropertyTypeString ;$objFile.Save ; Set new property value ;$objProperty = $objFile.CustomProperties.Item("CustomItem") ;$objProperty.Value = "CustomText" ;$objFile.Save ; Modify existing properties - Note: some wont allow writing to even if they exist in file ; more properties available - use DLL Export Viewer or OLE/COM Object Viewer 'oleview.exe' on dsofile.dll ; see also http://www.microsoft.com/technet/scriptcenter/resources/tales/sg0305.mspx for a list $objFile.SummaryProperties.Title = "Title" ; replace Title text here ;$objFile.SummaryProperties.Subject = "Subject" ;$objFile.SummaryProperties.Category = "Category" ;$objFile.SummaryProperties.Keywords = "Keywords" ;$objFile.SummaryProperties.Comments = "Comments" ;$objFile.SummaryProperties.Company = "Company" ;$objFile.SummaryProperties.Author = "Author" ;$objFile.SummaryProperties.RevisionNumber = "?" $objFile.Save ; save changes to file properties If $g_eventerror Then Exit $g_eventerror = 0 ; Retrieve custom properties values (if any) For $objProperty In $objFile.CustomProperties ConsoleWrite("+> " & $objProperty.Name & " : " & $objProperty.Value & @crlf) Next ; display a sampling of some properties of file $Title = $objFile.SummaryProperties.Title ConsoleWrite('-> $Title = ' & $Title & @crlf) $Subject = $objFile.SummaryProperties.Subject ConsoleWrite('-> $Subject = ' & $Subject & @crlf) $Category = $objFile.SummaryProperties.Category ConsoleWrite('-> $Category = ' & $Category & @crlf) $Keywords = $objFile.SummaryProperties.Keywords ConsoleWrite('-> $Keywords = ' & $Keywords & @crlf) $Comments = $objFile.SummaryProperties.Comments ConsoleWrite('-> $Comments = ' & $Comments & @crlf) $Company = $objFile.SummaryProperties.Company ConsoleWrite('-> $Company = ' & $Company & @crlf) $Author = $objFile.SummaryProperties.Author ConsoleWrite('-> $Author = ' & $Author & @crlf) $RevisionNumber = $objFile.SummaryProperties.RevisionNumber ConsoleWrite('-> $RevisionNumber = ' & $RevisionNumber & @crlf) $objFile.Close ; unbind from the summary information metadata attached to the file. Exit Func ComErrorHandler() ; optionally bypass message box, or use ConsoleWrite, Debugview or log errors to file Local $sHexNumber = Hex($oMyError.number,8) Local $sDesc = StringStripWS($oMyError.windescription, 2) Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $sHexNumber & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF) $g_eventerror = 1 ; something to check for when this function returns $oMyError.clear Endfunc Hey, that rocks! After downloading and installing DsoFile.dll it worked perfectly. I would rather be able to do this from the native enviroment, but this .dll is a great workaround. Thanks. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
felanor Posted May 25, 2008 Author Posted May 25, 2008 (edited) Rover, Thanks for that listing as well as the code you posted at the bottom. I've re-arranged some of it and created a UDF out of it. I'm going to be adding it to the example scripts section. Hopefully others will be getting some use out of this. ~Felanor expandcollapse popup;=============================================================================== ; ; Function Name: File Property Management ; Description: This utility is for reading/writing file properties ; Parameter(s): _FileProperty($fFile, $fProperty = "Title", $fValue = "", $fMode=0) ; $fFile - File path of file to be adjusted ; $fProperty - Property to be adjusted (title, subject, category, ; keywords, comments, company, author) ; $fValue - Value to insert into field ; $fMode - 0 for read, 1 for write, 2 for remove ; Requirement(s): DLL File in script directory - dsofile.dll ; Return Value(s): Property read if the read mode is specified. ; Author(s): Andrew Goulart ; ;=============================================================================== ; Func _FileProperty($fFile, $fProperty = "Title", $fValue = "", $fMode = 0) _DLLstartup() $return = "" Global $g_eventerror = 0; to be checked to know if com error occurs. Must be reset after handling. Global $oMyError = ObjEvent("AutoIt.Error", "ComErrorHandler"); Install a custom error handler $objFile = ObjCreate("DSOFile.OleDocumentProperties") If $g_eventerror Then Exit $g_eventerror = 0 If Not IsObj($objFile) Then Exit $objFile.Open($fFile); bind to the summary information metadata attached to the file. If $g_eventerror Then Exit $g_eventerror = 0 ; Remove properties Switch $fProperty Case "Title" Switch $fMode Case 0 $return = $objFile.SummaryProperties.Title Case 1 $objFile.SummaryProperties.Title = $fValue Case 2 $objFile.SummaryProperties.Title = "" EndSwitch Case "Subject" Switch $fMode Case 0 $return = $objFile.SummaryProperties.Subject Case 1 $objFile.SummaryProperties.Subject = $fValue Case 2 $objFile.SummaryProperties.Subject = "" EndSwitch Case "Category" Switch $fMode Case 0 $return = $objFile.SummaryProperties.Category Case 1 $objFile.SummaryProperties.Category = $fValue Case 2 $objFile.SummaryProperties.Category = "" EndSwitch Case "Keywords" Switch $fMode Case 0 $return = $objFile.SummaryProperties.Keywords Case 1 $objFile.SummaryProperties.Keywords = $fValue Case 2 $objFile.SummaryProperties.Keywords = "" EndSwitch Case "Comments" Switch $fMode Case 0 $return = $objFile.SummaryProperties.Comments Case 1 $objFile.SummaryProperties.Comments = $fValue Case 2 $objFile.SummaryProperties.Comments = "" EndSwitch Case "Company" Switch $fMode Case 0 $return = $objFile.SummaryProperties.Company Case 1 $objFile.SummaryProperties.Company = $fValue Case 2 $objFile.SummaryProperties.Company = "" EndSwitch Case "Author" Switch $fMode Case 0 $return = $objFile.SummaryProperties.Author Case 1 $objFile.SummaryProperties.Author = $fValue Case 2 $objFile.SummaryProperties.Author = "" EndSwitch EndSwitch $objFile.Save; save changes to file properties If $g_eventerror Then Exit $g_eventerror = 0 $objFile.Close; unbind from the summary information metadata attached to the file. If $return <> "" Then Return $return _DLLshutdown() EndFunc Func ComErrorHandler(); optionally bypass message box, or use ConsoleWrite, Debugview or log errors to file Local $sHexNumber = Hex($oMyError.number,8) Local $sDesc = StringStripWS($oMyError.windescription, 2) Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $sHexNumber & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF) $g_eventerror = 1; something to check for when this function returns $oMyError.clear Endfunc Func _DLLstartup($DLLpath = '') If $DLLpath = Default Or $DLLpath = '' Then $DLLpath = @ScriptDir & '\dsofile.dll' ShellExecuteWait('regsvr32', '/s /i ' & $DLLpath, @WindowsDir, 'open', @SW_HIDE) EndFunc ;==>_DLLstartup Func _DLLshutdown($DLLpath = '') If $DLLpath = Default Or $DLLpath = '' Then $DLLpath = @ScriptDir & '\dsofile.dll' ShellExecuteWait('regsvr32', ' /s /u ' & $DLLpath, @WindowsDir, 'open', @SW_HIDE) EndFunc ;==>_DLLshutdown Edited May 25, 2008 by felanor Check Out My ScriptsFile Property Management - Adjust a file's title, author, subject, etc.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now