Most up to date version is in this post.
Features
-Drag-drop folder onto script, or select from open dialog, or configure static input folder
-Runs multiple instances of Cr2hdr (or virtually anything else with minor editing)
-Easily add exiftool, dcraw, ptlens, etc. commands
-Files are sorted into folders upon completion
-Produces script log, as well as logs for each individual file conversion (broken now)
-Processing is timed
Directions
Copy and paste the code into a .vbs file. Edit the options at the top of the script (most importantly the location of cr2hdr.exe). "Maxprocs" is the number of instances of cr2hdr.exe to run at once.
Make sure all paths end with a "\", ie. "C:\cr2hdr\"
After editing, double click the .vbs file and it will present a dialog to browse for a folder (unless you add an input folder). Select a folder (on your hard drive, not CF) containing the mixed dual ISO .CR2s and plain .CR2s.
'------------------------------------------------------------------
'last update: 3/30/2014
cr2hdrpath="C:\cr2hdr\" 'ends with a slash \
cr2hdrexe="cr2hdr.exe"
cr2hdrargs="--compress"
exiftoolpath="C:\exiftool\" 'ends with a slash \
inputfolder="C:\pictures\" 'dialog will start at this folder if set (ends with a slash \)
dualisocr2dir="Dual ISO CR2"
regularcr2dir="Regular CR2"
dngoutputdir="Dual ISO DNG"
organize=true 'sort files into subdirectories when done processing
correcttint=false
maxprocs=4 'Number of simultaneous processes
windowtype=7
'0 Hide the window and activate another window.
'1 Activate and display the window. (restore size and position) Specify this flag when displaying a window for the first time.
'2 Activate & minimize.
'3 Activate & maximize.
'4 Restore. The active window remains active.
'5 Activate & Restore.
'6 Minimize & activate the next top-level window in the Z order.
'7 Minimize. The active window remains active.
'------------------------------------------------------------------
set elog=CreateObject("System.Collections.ArrayList")
elog.add "Started: " & Now()
starttime=Timer
'if inputfolder="" then 'not set in options
if Wscript.Arguments.Count>0 then
inputfolder=Wscript.Arguments(0) 'command line
else
inputfolder=getfolder("Select the folder containing the dual ISO .CR2 files.")
if inputfolder="" then WScript.Quit
end if
'end if
elog.add vbcrlf & "Input folder is " & inputfolder
set fso=CreateObject("Scripting.fileSystemObject")
set mainfolder=fso.GetFolder(inputfolder)
set files=mainfolder.Files
filecount=0
set cr2dngqueue=CreateObject("System.Collections.ArrayList")
set exiftoolqueue=CreateObject("System.Collections.ArrayList")
elog.add vbcrlf & "Searching for .CR2 files"
for Each file in files 'find applicable .cr2s
if valfname(file.Name,".CR2") then
cr2dngcmd="""" & cr2hdrpath & cr2hdrexe & """ " & cr2hdrargs & " """ & file.name & """" 'no logs
'cr2dngcmd="cmd.exe /c """"" & cr2hdrpath & cr2hdrexe & """ " & cr2hdrargs & " """ & file.name & """ > " & file.name & ".log """
cr2dngqueue.add cr2dngcmd
elog.add "Queued " & cr2dngcmd
if correcttint then
exiftoolcmd=exiftoolpath & "exiftool.exe " & replace(file.name,".CR2",".dng") & " -asshotneutral=""0.473635 1.05 0.624"" -overwrite_original"
exiftoolqueue.add exiftoolcmd
elog.add "Queued " & exiftoolcmd
end if
filecount=filecount+1
end if
next
if filecount=0 then
elog.add "No files found!"
msgbox "No files found!"
dump ""
WScript.Quit
end if
elog.add vbcrlf & "Converting Dual ISO .CR2 files"
cr2hdrtime=runqueue(cr2dngqueue,maxprocs,cr2hdrexe)
if correcttint then
runqueue exiftoolqueue,8,"exiftool.exe"
elog.add vbcrlf & "Running exiftool"
end if
dngcount=0
for Each file in files
if valfname(file.Name,".dng") then dngcount=dngcount+1
next
if dngcount=0 then
msg="No DNG files created. Check script options and log."
elog.add msg
msgbox msg
dump ""
WScript.Quit
end if
if organize then sortfiles
finishline="Processed " & filecount & " file(s). Converted " & dngcount & " Dual ISO(s). Runtime: " & round(Timer - starttime) & " seconds."
elog.add vbcrlf & finishline & vbcrlf
if organize then
mkdir mainfolder & "\" & "logs"
dump("\logs")
else
dump("")
end if
msgbox finishline
setnothing
sub sortfiles()
elog.add vbcrlf & "Moving Dual ISO .CR2 files"
set files=mainfolder.Files
for Each file in files
if valfname(file.Name,".dng") then 'find .dng but move .cr2 with same file name
mkdir mainfolder & "\" & dualisocr2dir
move mainfolder & "\" & fso.GetBaseName(file) & ".CR2", mainfolder & "\" & dualisocr2dir & "\" & fso.GetBaseName(file) & ".CR2"
end if
next
elog.add vbcrlf & "Moving any regular .CR2 files"
set files=mainfolder.Files
for Each file in files
if valfname(file.Name,".CR2") then
mkdir mainfolder & "\" & regularcr2dir
move mainfolder & "\" & file.Name, mainfolder & "\" & regularcr2dir & "\" & file.Name
end if
next
elog.add vbcrlf & "Moving Dual ISO .DNG files"
set files=mainfolder.Files
for Each file in files
if valfname(file.Name,".dng") then
mkdir mainfolder & "\" & dngoutputdir
move mainfolder & "\" & file.Name, mainfolder & "\" & dngoutputdir & "\" & file.Name
end if
next
elog.add vbcrlf & "Moving log files"
set files=mainfolder.Files
for Each file in files
if valfname(file.Name,".log") then
mkdir mainfolder & "\" & "logs"
move mainfolder & "\" & file.Name, mainfolder & "\" & "logs" & "\" & file.Name
end if
next
end sub
function runqueue(queue,instances,exename)
t=Timer
Set WshShell=WScript.CreateObject("WScript.Shell")
WshShell.currentdirectory=inputfolder 'have to set the current directory; can't pass full file path because of how cr2hdr calls adngc
for Each line in queue
elog.add "Executing: " & line
wshshell.run line,windowtype,false
waitfinish instances,exename
next
waitfinish 1,exename
runqueue=Timer-t 'return elapsed time
Set WshShell=nothing
end function
sub waitfinish(instances,exename)
do
Set myproc=GetObject("Winmgmts:").Execquery("Select * from Win32_Process where name='" & exename & "'")
if(myproc.count>=instances) then wscript.sleep 100
loop while myproc.count>=instances
end sub
function getfolder(title)
MY_COMPUTER = &H11&
USER_PROFILE = &H28&
MY_PICTURES = &H27&
WINDOW_HANDLE = 0
OPTIONS = &H10&
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_PICTURES)
Set objFolderItem = objFolder.Self
if inputfolder<>"" then strpath=inputfolder else strpath=objFolderItem.Path
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder _
(WINDOW_HANDLE, title, OPTIONS, strPath)
If objFolder Is Nothing Then
Wscript.Quit
End If
Set objFolderItem = objFolder.Self
getfolder = objFolderItem.Path
end function
sub dump(subfolder)
dim objfile
set objFile=fso.CreateTextFile(mainfolder & subfolder & "\dualISOscript.log",True)
objFile.Write Join(elog.toarray(), chr(13) & chr(10))
objFile.Close
end sub
sub setnothing()
set objfile=nothing
set cr2dngqueue=nothing
set adngcqueue=nothing
set deldngqueue=nothing
set elog=nothing
set fso=nothing
end sub
function valfname(name,suffix)
valfname=lcase(Right(name,len(suffix)))=lcase(suffix)
end function
sub mkdir(dir)
if not fso.FolderExists(dir) then
fso.createFolder(dir)
elog.add "Created """ & dir & """"
end if
end sub
sub move(src,dest)
elog.add "Moving """ & src & """ to """ & dest & """"
fso.MoveFile src,dest
end sub
function round(num)
round=int((num+.005)*100)/100
end function