Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: GetDetailsOf DSO File Properties Summary
; Winbatch - Updated Script for File Properties, combines DSO and GetDetailsOf() ; DSO Package available at: http://support.microsoft.com/kb/224351 ; ; Stan Littlefield, December 2, 2010 ;////////////////////////////////////////////////////////////////////////////////////////////////////////////// ; NOTE: these is a glitch in the DSOfile.dll which will not allow updating a file SummaryProperty if ; an entry does not already exists. The link below contains a .cpp snippet so you can re-compile ; the DSO build (source comes as part of DSO package) ; ; http://www.codenewsgroups.net/vb/t8391-solution-dsofile-dll-permission-denied.aspx ; ; ;////////////////////////////////////////////////////////////////////////////////////////////////////////////// ; Revised: 12/3/2010 - ; GetDetailsOf() now reads from text files and creates them if they do not exist ; this permits having an accurate property index for a particular OS version ; ; Properties that ="" no longer included in final display ; ; OLE Properties now in separate UDF with errorhandler. This this for instances where ; a Microsoft Office document is scanned on a PC w/out Office Installed ; ; Added UDFS to add/remove/update a Custom Property - requires DSOFile.dll ;////////////////////////////////////////////////////////////////////////////////////////////////////////////// GoSub udfs IntControl(73,1,0,0,0) oDSO=0 oProps=0 types="All Files|*.*|" file=AskFilename("SelectFile",DirScript(), types, "", 1) txt = "[DSO_GetProperties]":@CRLF ;check is DSO is available If ! IsInReg("DSOFile.OLEDocumentProperties") Then Goto final oDSO = CreateObject("DSOFile.OLEDocumentProperties") isOffice=0 isOlE=0 ;is file an Office Document If StrIndexNC("DOC/MDB/XLS/PPT",FileExtension(file),0,@FWDSCAN) oDSO.Open(file,0,1) ;open with Extended Properties isOffice=1 Else oDSO.Open(file,0,0) EndIf If oDSO.IsOleFile==-1 Then isOLE=1 txt=txt:"File=":file:@CRLF txt=txt:"isOLE=":isOLE:@CRLF txt=txt:GetSummary(oDSO.SummaryProperties) ;enumerates MS Standard Summary Properties ;additional info for OLE Document Types If isOLE Then txt=txt:GetOle(oDSO) ;Custom Properties - Can be set for most files ;Try adding the property Sentry [below] then uncomment the RemoveCustom() ;AddCustom(oDSO.CustomProperties,"Sentry","ON") ;run this first ;RemoveCustom(oDSO.CustomProperties,"Sentry") ;run against same file after Sentry is added n= oDSO.CustomProperties.Count If n>0 txt=txt:"[Custom_Properties]":@CRLF ForEach prop In oDSO.CustomProperties txt=txt:prop.Name:"=":prop.Value:@CRLF Next EndIf :End oDSO.Save() oDSO.Close() oDSO=0 :final ;this may cause some redundancy with DSO but for files like jpg, PDF can obtain stuff ;DSO misses txt=txt:"[Additional_Properties]":@CRLF ;use GetDetailsOf() shell method txt=txt:FileSummary(file) Message("Properties for %file%",txt) Exit ;////////////////////////////////////////////////////////////////////////////////////////////////////////////// :WBERRORHANDLER ErrorProcessing(0,1,0,0) IntControl(73,1,0,0,0) oDSO=0 Exit ;////////////////////////////////////////////////////////////////////////////////////////////////////////////// :udfs #DefineFunction AddCustom(oProps,name,value) ;just for practice IntControl(73,1,0,0,0) canAdd=1 ForEach prop In oProps If prop.Name==name Then canAdd=0 Next If canAdd Then oProps.Add(name,value) Return(1) :WBERRORHANDLER IntControl(73,1,0,0,0) Display(2,"Error","Cannot Add Custom Property") Return(0) #EndFunction #DefineFunction RemoveCustom(oProps,name) ;just for practice IntControl(73,1,0,0,0) ForEach prop In oProps If prop.Name==name Then oProps.Item(name).Remove() Next Return(1) :WBERRORHANDLER IntControl(73,1,0,0,0) Display(2,"Error","Cannot Remove Custom Property") Return(0) #EndFunction #DefineFunction UpdCustom(oProps,name,value) ;just for practice IntControl(73,1,0,0,0) ForEach prop In oProps If prop.Name==name Then oProps.Item(name).Value=value Next Return(1) :WBERRORHANDLER IntControl(73,1,0,0,0) Display(2,"Error","Cannot Update Custom Property") Return(0) #EndFunction #DefineFunction GetOle(oDSO) IntControl(73,1,0,0,0) retval="" retval=retval:"CLSID=":oDSO.CLSID:@CRLF retval=retval:"ProgID=":oDSO.progID:@CRLF retval=retval:"OLEDocumentFormat=":oDSO.OleDocumentFormat:@CRLF Return(retval) :WBERRORHANDLER IntControl(73,1,0,0,0) Return("OLE=Cannot Get OLE Properties":@CRLF) #EndFunction #DefineFunction GetSummary(oProps) retval="" If oProps.ApplicationName<>"" Then retval=retval:"ApplicationName=":oProps.ApplicationName:@CRLF If oProps.Author<>"" Then retval=retval:"Author=":oProps.Author:@CRLF If oProps.Version<>"" Then retval=retval:"Version=":oProps.Version:@CRLF If oProps.Subject<>"" Then retval=retval:"Subject=":oProps.Subject:@CRLF If oProps.Category<>"" Then retval=retval:"Category=":oProps.Category:@CRLF If oProps.Company<>"" Then retval=retval:"Company=":oProps.Company :@CRLF If oProps.Keywords<>"" Then retval=retval:"Keywords=":oProps.Keywords:@CRLF If oProps.Manager<>"" Then retval=retval:"Manager=":oProps.Manager:@CRLF If oProps.LastSavedBy<>"" Then retval=retval:"LastSavedBy=":oProps.LastSavedBy:@CRLF If oProps.WordCount<>"" Then retval=retval:"WordCount=":oProps.WordCount:@CRLF If oProps.PageCount<>"" Then retval=retval:"PageCount=":oProps.PageCount:@CRLF If oProps.ParagraphCount<>"" Then retval=retval:"ParagraphCount=":oProps.ParagraphCount:@CRLF If oProps.LineCount<>"" Then retval=retval:"LineCount=":oProps.LineCount:@CRLF If oProps.CharacterCount<>"" Then retval=retval:"CharacterCount=":oProps.CharacterCount:@CRLF If oProps.CharacterCountWithSpaces<>"" Then retval=retval:"CharacterCountWithSpaces=":oProps.CharacterCountWithSpaces:@CRLF If oProps.ByteCount<>"" Then retval=retval:"ByteCount=":oProps.ByteCount:@CRLF If oProps.PresentationFormat<>"" Then retval=retval:"PresentationFormat=":oProps.PresentationFormat:@CRLF If oProps.SlideCount<>"" Then retval=retval:"SlideCount=":oProps.SlideCount:@CRLF If oProps.NoteCount<>"" Then retval=retval:"NoteCount=":oProps.NoteCount:@CRLF If oProps.HiddenSlideCount<>"" Then retval=retval:"HiddenSlideCount=":oProps.HiddenSlideCount:@CRLF If oProps.MultimediaClipCount<>"" Then retval=retval:"MultimediaClipCount=":oProps.MultimediaClipCount:@CRLF If oProps.DateCreated<>"" Then retval=retval:"DateCreated=":oProps.DateCreated:@CRLF If oProps.DateLastPrinted<>"" Then retval=retval:"DateLastPrinted=":oProps.DateLastPrinted:@CRLF If oProps.DateLastSaved<>"" Then retval=retval:"DateLastSaved=":oProps.DateLastSaved:@CRLF If oProps.TotalEditTime<>"" Then retval=retval:"TotalEditTime=":oProps.TotalEditTime:@CRLF If oProps.Template<>"" Then retval=retval:"Template=":oProps.Template:@CRLF If oProps.RevisionNumber<>"" Then retval=retval:"RevisionNumber=":oProps.RevisionNumber:@CRLF If oProps.SharedDocument<>"" Then retval=retval:"SharedDocument=":oProps.SharedDocument:@CRLF Return(retval) #EndFunction #DefineFunction FileSummary (File) IntControl(73,1,0,0,0) aFile=DirScript():"catt.txt" iFile=DirScript():"natt.txt" If !FileExist(aFile) && !FileExist(iFile) Then CreateProps() cAtt=FileGet(aFile) nAtt=FileGet(iFile) If !FileExist(File) Pause( "FileSummary Error", "Unable to locate specified file: " : file) Return 0 EndIf n=ItemCount(cAtt,",") strFileName = FileBaseName(File) strPathName = FilePath(File) objShell = CreateObject("Shell.Application") objFolder = objShell.Namespace(strPathName) detail="" For i=1 To n c=ItemExtract(i,cAtt,",") n1=ItemExtract(i,nAtt,",") new=objFolder.GetDetailsOf(objFolder.ParseName(strFileName), n1) If new<>"" Then detail = detail:c:"=":new:@CRLF Next objShell = 0 Return(detail) :WBERRORHANDLER IntControl(73,1,0,0,0) Return(detail) #EndFunction #DefineFunction CreateProps() aFile=DirScript():"catt.txt" iFile=DirScript():"natt.txt" oShell = CreateObject("Shell.Application") oFolder = oShell.Namespace(0) Null=ObjectType("NULL","") cAtt="" nAtt="" For i = 0 To 99 Prop = oFolder.GetDetailsOf(Null, i) ;pass Null to enumerate If Prop==Null Then Continue ;skip if not found or reserved cAtt=cAtt:Prop:"," nAtt=nAtt:i:"," Next cAtt=StrSub(cAtt,1,StrLen(cAtt)-1) nAtt=StrSub(nAtt,1,StrLen(nAtt)-1) FilePut(aFile,cAtt) FilePut(iFile,nAtt) oFolder=0 oShell=0 Return(1) #EndFunction #DefineSubRoutine ErrorProcessing(deleteIni,showerr,logfile,Err_Array) If VarType(Err_Array) ==256 WbError = Err_Array[0] wberrorhandlerline = Err_Array[1] wberrorhandleroffset = Err_Array[2] wberrorhandlerassignment = Err_Array[3] wberrorhandlerfile = Err_Array[4] wberrortextstring = Err_Array[5] wberroradditionalinfo = Err_Array[6] wberrorinsegment = Err_Array[7] Else WbError = LastError() EndIf WbTextcode = WbError If WbError==1668||WbError==2669||WbError==3670 WbError = ItemExtract(1,IntControl(34,-1,0,0,0),":") WbTextcode = -1 EndIf WbErrorString = IntControl(34,WbTextcode,0,0,0) WbErrorDateTime = TimeYmdHms() If deleteIni WbErrorFile = StrCat(ShortCutDir( 'AppData', 0, 0 ),'\WinBatch\Settings\') If ! DirExist(WbErrorFile) Then WbErrorFile = DirWindows(0) WbErrorFile = StrCat(WbErrorFile,"WWWBATCH.INI") FileDelete(WbErrorFile) IniWritePvt(WbErrorDateTime,"CurrentScript",WbErrorHandlerFile ,WbErrorFile) IniWritePvt(WbErrorDateTime,"ErrorValue" ,WbError ,WbErrorFile) IniWritePvt(WbErrorDateTime,"ErrorString" ,WbErrorString ,WbErrorFile) IniWritePvt(WbErrorDateTime,"ScriptLine" ,WbErrorHandlerLine ,WbErrorFile) IniWritePvt(WbErrorDateTime,"ScriptOffset" ,WbErrorHandlerOffset ,WbErrorFile) IniWritePvt(WbErrorDateTime,"VarAssignment",WbErrorHandlerAssignment,WbErrorFile) IniWritePvt(WbErrorDateTime,"VarInSegment" ,WbErrorInSegment,WbErrorFile) IniWritePvt("","","",WbErrorFile) EndIf WbErrorMsgText = StrCat(WbErrorDateTime,@CRLF) WbErrorMsgText = StrCat(WbErrorMsgText,"Current Script: ",WbErrorHandlerFile,@CRLF) WbErrorMsgText = StrCat(WbErrorMsgText,"Error# [",WbError,"]",@CRLF) WbErrorMsgText = StrCat(WbErrorMsgText,"Error Text: ",wberrortextstring,@CRLF) WbErrorMsgText = StrCat(WbErrorMsgText,"[Extended Information] ",wberroradditionalinfo,@CRLF,@CRLF) WbErrorMsgText = StrCat(WbErrorMsgText,"On Line:",@CRLF,WbErrorHandlerLine,@CRLF) ;WbErrorMsgText = StrCat(WbErrorMsgText,"Offset: ",WbErrorHandlerOffset,@CRLF) If (WbErrorHandlerAssignment>"") Then %WbErrorHandlerAssignment% = "UNKNOWN" WbErrorMsgText = StrCat(WbErrorMsgText,"Assignment/Variable: ",WbErrorHandlerAssignment,@CRLF) If (WbErrorInSegment>"") Then WbErrorMsgText = StrCat(WbErrorMsgText,"In UDF/UDS: ",WbErrorInSegment,@CRLF) If logfile cSep = StrCat(StrFill("=",50),@CRLF) cLogFile = StrCat(DirScript(),"log.err") If ! FileExist(cLogFile) Then FilePut(cLogFile,StrCat("Error Log",@CRLF,cSep)) FilePut(cLogFile,StrCat(FileGet(cLogFile),WbErrorMsgText,cSep)) Display(2,"An Error Occured",StrCat("written to ",cLogFile)) Else If showerr WbErrorMsgText = StrCat(WbErrorMsgText,"[THIS ERROR NOT WRITTEN TO LOG FILE]",@CRLF) Message("An Error Was Encountered",WbErrorMsgText) EndIf EndIf Return(1) #EndSubRoutine #DefineFunction isInReg(cProg) Return( RegExistKey(@REGCLASSES,cProg) ) #EndFunction Return ;//////////////////////////////////////////////////////////////////////////////////////////////////////////////
Article ID: W18072
Filename: Get All File Properties.txt
File Created: 2010:12:02:14:37:08
Last Updated: 2010:12:02:14:37:08