Hi folks,
I'm working on a function to add missing EXIF informations to files using their filename.
I coded it in VBScript and it works so far...
Now I' like to have a progressbar to show me how long the process will take.
Here's my working code without progress bar:
Option Explicit
Function OnClick(ByRef ClickData)
Dim strFileName
Dim arrFileName
Dim strDate
Dim strTime
Dim strDateTime
Dim strCommand
Dim x
Dim DOpusRTPath
DOpusRTPath = "C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe"
Dim Shell
Set Shell = CreateObject("WScript.Shell")
arrFileName = Array()
for each strFileName in ClickData.func.sourcetab.selected_files
arrFileName = split(strFileName, " - ")
if ubound(arrFileName) = 1 then
strDate = replace(right(arrFileName(0),10),"-",":")
strTime = replace(left(arrFileName(1),8),".",":")
end if
if len(strTime) < 8 then WScript.Quit
strDateTime = strDate & " " & strTime
strCommand = "C:\Windows\exiftool.exe -createdate=""" & strDateTime & """ """ & strFileName & """"
Shell.Run strCommand,0,True
strCommand = "C:\Windows\exiftool.exe -datetimeoriginal=""" & strDateTime & """ """ & strFileName & """"
Shell.Run strCommand,0,True
strCommand = """" & DOpusRTPath & """ /cmd SetAttr FILE=""" & strFileName & """ CREATED=""" & replace(strDate,":","-") & " " & strTime & """ MODIFIED=""" & replace(strDate,":","-") & " " & strTime & """"
Shell.Run strCommand,0,true
strCommand = "cmd /c del """ & strFileName & "_original"""
Shell.Run strCommand,0,True
next
End Function
...and here my first try to implement the progress property (doesn't work)
Option Explicit
Function OnClick(ByRef ClickData)
Dim strFileName
Dim arrFileName
Dim strDate
Dim strTime
Dim strDateTime
Dim strCommand
Dim x
dim DOpusRTPath
DOpusRTPath = "C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe"
Dim Shell
Set Shell = CreateObject("WScript.Shell")
Dim Files
Files = ClickData.func.sourcetab.selected_files
Dim Progress
Progress = ClickData.func.command.progress
Progress.pause = false 'Allow pause button or not.
Progress.abort = false 'Allow abort button or not.
Progress.Init = clickData.func.sourcetab
Progress.AddFiles = Files.count
Progress.Show
arrFileName = Array()
for each strFileName in Files 'ClickData.func.sourcetab.selected_files
arrFileName = split(strFileName, " - ")
if ubound(arrFileName) = 1 then
strDate = replace(right(arrFileName(0),10),"-",":")
strTime = replace(left(arrFileName(1),8),".",":")
end if
if len(strTime) < 8 then WScript.Quit
strDateTime = strDate & " " & strTime
strCommand = "C:\Windows\exiftool.exe -createdate=""" & strDateTime & """ """ & strFileName & """"
Shell.Run strCommand,0,True
strCommand = "C:\Windows\exiftool.exe -datetimeoriginal=""" & strDateTime & """ """ & strFileName & """"
Shell.Run strCommand,0,True
strCommand = """" & DOpusRTPath & """ /cmd SetAttr FILE=""" & strFileName & """ CREATED=""" & replace(strDate,":","-") & " " & strTime & """ MODIFIED=""" & replace(strDate,":","-") & " " & strTime & """"
Shell.Run strCommand,0,true
strCommand = "cmd /c del """ & strFileName & "_original"""
Shell.Run strCommand,0,True
Progress.StepFiles = 1
next
End Function
Is there somebody who can help me?
regards,
Berndi