KJohn Posted February 5, 2007 Posted February 5, 2007 How would you go about querying a file's metadata from within autoit? For example: Getting the Album title of an MP3 file or getting the author of a Microsoft Word document... I hope u get the idea... I don't see any need to further elaborate this question..
mrbond007 Posted February 5, 2007 Posted February 5, 2007 How would you go about querying a file's metadata from within autoit? For example: Getting the Album title of an MP3 file or getting the author of a Microsoft Word document... I hope u get the idea... I don't see any need to further elaborate this question..it's difficult but try looking here :http://www.autoitscript.com/forum/index.ph...amp;hl=metadata Projects : Space Regain - Memory Fusion - PWGT - Chip-ITGames : BrainPain - BrainPain Director's Cut - ProSpeed Games Pack (New)Vista vs XP : the forbidden fight
nobbe Posted February 5, 2007 Posted February 5, 2007 hi its easy with the code from Simucal expandcollapse popup$path = FileOpenDialog("Select a file to read attributes",@ScriptDir,"All (*.*)") $prop = _GetExtProperty($path,-1) _ArrayDisplay($prop,"Property Array") ;=============================================================================== ; Function Name: GetExtProperty($sPath,$iProp) ; Description: Returns an extended property of a given file. ; Parameter(s): $sPath - The path to the file you are attempting to retrieve an extended property from. ; $iProp - The numerical value for the property you want returned. If $iProp is is set ; to -1 then all properties will be returned in a 1 dimensional array in their corresponding order. ; The properties are as follows: ; Name = 0 ; Size = 1 ; Type = 2 ; DateModified = 3 ; DateCreated = 4 ; DateAccessed = 5 ; Attributes = 6 ; Status = 7 ; Owner = 8 ; Author = 9 ; Title = 10 ; Subject = 11 ; Category = 12 ; Pages = 13 ; Comments = 14 ; Copyright = 15 ; Artist = 16 ; AlbumTitle = 17 ; Year = 18 ; TrackNumber = 19 ; Genre = 20 ; Duration = 21 ; BitRate = 22 ; Protected = 23 ; CameraModel = 24 ; DatePictureTaken = 25 ; Dimensions = 26 ; Width = 27 ; Height = 28 ; Company = 30 ; Description = 31 ; FileVersion = 32 ; ProductName = 33 ; ProductVersion = 34 ; Requirement(s): File specified in $spath must exist. ; Return Value(s): On Success - The extended file property, or if $iProp = -1 then an array with all properties ; On Failure - 0, @Error - 1 (If file does not exist) ; Author(s): Simucal (Simucal@gmail.com) ; Note(s): ; ;=============================================================================== Func _GetExtProperty($sPath, $iProp) Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sProperty $iExist = FileExists($sPath) If $iExist = 0 Then SetError(1) Return 0 Else $sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1)) $sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1))) $oShellApp = ObjCreate("shell.application") $oDir = $oShellApp.NameSpace ($sDir) $oFile = $oDir.Parsename ($sFile) If $iProp = -1 Then Local $aProperty[35] For $i = 0 To 34 $aProperty[$i] = $oDir.GetDetailsOf ($oFile, $i) Next Return $aProperty Else $sProperty = $oDir.GetDetailsOf ($oFile, $iProp) If $sProperty = "" Then Return 0 Else Return $sProperty EndIf EndIf EndIf EndFunc ;==>_GetExtProperty
Sorn Posted February 5, 2007 Posted February 5, 2007 Beat me too it guys, however editing that data is pretty difficult. That is where I'm stuck on I'm trying to mess with the DSOFile.dll from microsoft but I must be doing something wrong because it keeps returning the error Variable must be 'object' type. grrr! lol Good luck
KJohn Posted February 6, 2007 Author Posted February 6, 2007 @mrbond007 and @nobbe: thanks a lot for the really prompt reply!! u guys r the greatest! note: i havn't tested this right now, i'll post back here if i run into problems...
/dev/null Posted February 6, 2007 Posted February 6, 2007 Beat me too it guys, however editing that data is pretty difficult. That is where I'm stuck on I'm trying to mess with the DSOFile.dll from microsoft but I must be doing something wrong because it keeps returning the error Variable must be 'object' type. grrr! lol Good luckdownload the thing and have a look at the demo source code for VB6. http://www.microsoft.com/downloads/details...;displaylang=en __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
nexo Posted April 27, 2007 Posted April 27, 2007 Beat me too it guys, however editing that data is pretty difficult. That is where I'm stuck on I'm trying to mess with the DSOFile.dll from microsoft but I must be doing something wrong because it keeps returning the error Variable must be 'object' type. grrr! lol Good luckHi, i was looking for the same thing.Search "dsofile" at http://www.microsoft.com/downloads ; download it (free use).First register that DLL (regsvr32 path\dsofile.dll).CODE$path = FileOpenDialog("Choose file (to read/modif some properties)",@ScriptDir,"All (*.*)")$objPropertyReader = ObjCreate("DSOleFile.PropertyReader")$objDocument = $objPropertyReader.GetDocumentProperties ($path) ;read Keywords and TitleMsgBox(0, "Keywords property", $objdocument.Keywords)MsgBox(0, "Title property", $objdocument.Title) ; change Keywords and Title$objdocument.Keywords = InputBox("input the new Keywords", "new keywordds")$objdocument.Title = InputBox("enter the new Title", "new Title :")MsgBox(0, "news Keywords of that file", $objdocument.Keywords)MsgBox(0, "new Title", $objdocument.Title)Limitation : it only works with OLE compatible file types (MSOffice...). It doesn't work with OpenOffice files.
PsaltyDS Posted April 27, 2007 Posted April 27, 2007 (edited) hi its easy with the code from Simucal expandcollapse popup$path = FileOpenDialog("Select a file to read attributes",@ScriptDir,"All (*.*)") $prop = _GetExtProperty($path,-1) _ArrayDisplay($prop,"Property Array") ;=============================================================================== ; Function Name: GetExtProperty($sPath,$iProp) ; Description: Returns an extended property of a given file. ; Parameter(s): $sPath - The path to the file you are attempting to retrieve an extended property from. ; $iProp - The numerical value for the property you want returned. If $iProp is is set ; to -1 then all properties will be returned in a 1 dimensional array in their corresponding order. ; The properties are as follows: ; Name = 0 ; Size = 1 ; Type = 2 ; DateModified = 3 ; DateCreated = 4 ; DateAccessed = 5 ; Attributes = 6 ; Status = 7 ; Owner = 8 ; Author = 9 ; Title = 10 ; Subject = 11 ; Category = 12 ; Pages = 13 ; Comments = 14 ; Copyright = 15 ; Artist = 16 ; AlbumTitle = 17 ; Year = 18 ; TrackNumber = 19 ; Genre = 20 ; Duration = 21 ; BitRate = 22 ; Protected = 23 ; CameraModel = 24 ; DatePictureTaken = 25 ; Dimensions = 26 ; Width = 27 ; Height = 28 ; Company = 30 ; Description = 31 ; FileVersion = 32 ; ProductName = 33 ; ProductVersion = 34 ; Requirement(s): File specified in $spath must exist. ; Return Value(s): On Success - The extended file property, or if $iProp = -1 then an array with all properties ; On Failure - 0, @Error - 1 (If file does not exist) ; Author(s): Simucal (Simucal@gmail.com) ; Note(s): ; ;=============================================================================== Func _GetExtProperty($sPath, $iProp) Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sProperty $iExist = FileExists($sPath) If $iExist = 0 Then SetError(1) Return 0 Else $sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1)) $sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1))) $oShellApp = ObjCreate("shell.application") $oDir = $oShellApp.NameSpace ($sDir) $oFile = $oDir.Parsename ($sFile) If $iProp = -1 Then Local $aProperty[35] For $i = 0 To 34 $aProperty[$i] = $oDir.GetDetailsOf ($oFile, $i) Next Return $aProperty Else $sProperty = $oDir.GetDetailsOf ($oFile, $iProp) If $sProperty = "" Then Return 0 Else Return $sProperty EndIf EndIf EndIf EndFunc ;==>_GetExtPropertyoÝ÷ Û÷(uæèÇú®¢×D@-bëaj×îËb¢{("f§Wا¶¯z»"¢{ajÛh¢H§¦ëij¶¦z׫²Ø^Á¬Á©íyض(v'âyÛayצ¢Ç+ij»m¢ÈhÂ߶§{¥¦â+bzÄáy¶¬Çb}÷«zw±ªÞw^ÝB©ày×îËb¢yÚçë¢a´Lm>º)z»r¶bá´Lm>º)¶+¢êbµ¼§jh§Ê'½éíðØmê-êÅW[61§^¢b¢v¥Ó~¢>º) I had hoped to make a quick _FileSetExtProp() out of this, but Microsoft seems determined to prevent that. Additionally, there is a known XP bug feature that will only display the first 9 properties (0 thru 8) even if more are set. Be sure to try it with your version of Windows as this is sensitive to SP level and KB's applied. Edited April 27, 2007 by PsaltyDS 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
Achilles Posted July 23, 2007 Posted July 23, 2007 I had hoped to make a quick _FileSetExtProp() out of this, but Microsoft seems determined to prevent that.So is there no way to set the properties of a mp3 file? My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
PsaltyDS Posted May 24, 2008 Posted May 24, 2008 So is there no way to set the properties of a mp3 file?Resurrecting an old topic to point out some new information on setting file meta data using the DsoFile.dll (see: Tales from the Script - March 2005: Dsofile: The Untold Story), which can be downloaded from Microsoft's KB224351.After installing DsoFile.dll I tried out the demo script by rover, and it worked. 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
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