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
That is supergreen, thank you very much :-)
Ok, I am vbs ileterate.
Copied the script to notepad and saved it as file.vbs
Put the directory of my cr2hdr.exe as:
path="F:\0-cr2hdr"
Saved the file.
Double click and ask for the directory for the files, so far it works.
I cannot get it to work with the :
imgprefix="img_"
'imgprefix="DUAL"
imgsuffix=".CR2"
I tried renaming my files to DUALXXXX.CR2
and the script cannot find files.
How should I rename the files?
U should have it like this, if your prefix is DUAL:
'imgprefix="img_"
imgprefix="DUAL"
If I uderstand correctly you are saying that we have two options in the script and by adding the little ' mark infront then we are commenting out that option.
So:
'imgprefix="img_"
imgprefix="DUAL"
means ingnore the prefix: 'imgprefix="img_"
and use the prefix: imgprefix="DUAL"
So I rename my files to: DUAL__002544.CR2
And the script does not find them? What am I doing wrong?
Quote from: RenatoPhoto on September 26, 2013, 02:09:56 PM
If I uderstand correctly you are saying that we have two options in the script and by adding the little ' mark infront then we are commenting out that option.
So:
'imgprefix="img_"
imgprefix="DUAL"
means ingnore the prefix: 'imgprefix="img_"
and use the prefix: imgprefix="DUAL"
correct
Quote
So I rename my files to: DUAL__002544.CR2
And the script does not find them? What am I doing wrong?
I do not fully understand, what R U asking, I am sorry.
In fact, actually I have prefix "_UAL" - like this: _UAL2516.CR2,
so I renamed it at line:
imgprefix="_UAL"and it worked like a charm.
Try to check your settings. Did you set the right path for cr2hdr.exe at:
path="C:\Users\blah\Documents\cr2hdr" ?
Quote from: jOt on September 24, 2013, 01:38:28 PM
...so no developers interested in modification of cr2hdr to have manual control instead of automatic detection of fields order? Maybe easier than implementing command line would be 4 versions of cr2hdr, since there is 4 combination of fields order?
I think I made the correct changes from what Alex said, here are the 4 versions plus the normal one. Like always make sure the file is in the same folder as the EXE file when you drag and drop to convert.
https://bitbucket.org/mk11174/magic-lantern/downloads/cr2hdr_combo.zip (https://bitbucket.org/mk11174/magic-lantern/downloads/cr2hdr_combo.zip)
Ok, now I got it working. I must have typed something wrong.
I also changed my path back to :
path="C:\Users\RE\Documents\cr2hdr"
Also I put the latest cr2hdr.exe with the exif.exe and dcraw.exe (http://acoutts.com/a1ex/cr2hdr.zip) in the new directory C:\Users\RE\Documents\cr2hdr
I am using windows 7, and every time the cr2hdr.exe is used I get some security pop up. Is there a way to disable this security check so that the script runs without my attention..
I had that problem too before but it went away by itself. I don't know what I did. I found this though: http://www.sevenforums.com/tutorials/182353-open-file-security-warning-enable-disable.html
Quote from: RenatoPhoto on September 26, 2013, 05:58:26 PM
I am using windows 7, and every time the cr2hdr.exe is used I get some security pop up. Is there a way to disable this security check so that the script runs without my attention..
For windows 7 64 bit the easy way: Right click on cr2hdr.exe, select properties, go the bottom of popup and there are two buttons, one is Advanced and the other is a button to unlock this file.
Click Unlock and it will not give the security pop anymore...
This script is now running smooth!
Hi, engardeknave
it would be nice if your script could delete successfully converted cr2s (only).
Could you add that feature into your script, please?
We really do not need those cr2 files anymore after conversion.
Thank you.
Beg to differ.... Maybe an option to do that, I always like to keep the originals.
It's a really bad idea to put that much trust in either cr2hdr or the script. There's no way to know every file was converted successfully without manually checking.
Thanks engardeknave for this. It's Great!
Is there a way to set the CR2 image path to a folder instead of the dialog box?
*EDIT*
Never mind, I figured it out. Just had to read through it..
For others like me, I changed:
inputfolder=InputBox("Enter the path to the dual ISO shots.","Dual ISO Script")
to
inputfolder="D:\NewPhotos\DUALISO"
Updated to compress DNGs.
Notes:
Install Adobe DNG Convertor (https://www.adobe.com/support/downloads/thankyou.jsp?ftpID=5646&fileID=5658).
Enter the paths for everything at the top. Choose whether or not you want the original DNGs to be deleted (deleteoriginaldng=true/false).
There are a few options for the DNG convertor that can be changed, notably whether or not you want jpg previews. (The previews are not exactly accurate.)
Remember, this will only find and convert .CR2 files.
You may want to add these options for the DNG converter: -lossy, -side and -count.
http://feedback.photoshop.com/photoshop_family/topics/dng_converter_what_is_the_command_line_option_for_lossy_compression
Don't use -lossy with dual ISO files.
Quote from: engardeknave on October 27, 2013, 03:43:18 AM
There are a few options for the DNG convertor that can be changed, notably whether or not you want jpg previews. (The previews are not exactly accurate.)
The jpeg previews are useless if you are using Lightroom or PS, they are only used by (far in between) 3rd party apps. For the Adobe apps "-p0 -fl" makes more sense since it embeds "Fast Load Data" which speeds up initial rendering.
Quote from: a1ex on October 27, 2013, 07:53:37 AMDon't use -lossy with dual ISO files.
Ugh? Interesting (I didn't try yet) - why would lossy compression work on converted dual_iso files? Or are you talking of the original cr2, but that's to be processed by cr2hdr before acr?
Quote
- Don't use -lossy with dual ISO files.
- Ugh? Interesting (I didn't try yet) - why would lossy compression work on converted dual_iso files?
Here's why:
(http://a1ex.magiclantern.fm/bleeding-edge/dng_lossless.jpg) (http://a1ex.magiclantern.fm/bleeding-edge/dng_lossy.jpg)
Quote from: a1ex on October 27, 2013, 09:34:07 AM
Here's why
Edit: After trying to convert some dng to lossy, I see you're correct - but the problems are much more subtle than in your sample, the lossy dng has horizontal stripes which I wouldn't have spotted if I wouldn't have looked closely at 100% crop.
It would be nice to get this fixed if possible, lossy dng is really comfortable to reduce the disk storage of bulk shots (I often use it for focus stack source files) and also for general archival with reduced resolution.
I can't see any stripes on the shots I've tried.
FYI, the lossy DNGs are 8-bit. Regular Canon CR2's have 14 bits, from which 3 or more are mostly noise, so the converter is probably optimized for mapping 11 bits into 8 with a nonlinear curve. Dual ISO DNGs have 16 bits, from which 1 or 2 bits are noise; if you apply the same curve used for regular CR2, you lose shadow detail. So, the fix has to be in the DNG converter, not in cr2hdr.
For the same reason, you shouldn't trim the 14-bit raw video data to 10 bits without a LUT. If you only throw away 2 bits it may not be noticeable unless you do extreme color grading, but if you throw 4, you may have surprises.
IS this working for mac?
Quote from: Danne on October 28, 2013, 11:50:53 AM
IS this working for mac?
Nope, this script is for Windows (scripting host).
I'd like to propose a new feature - allow any CR2 files that were successfully processed as dual-ISO to be moved out to another directory (same as the compressed DNGs can be). I want this because I typically have all my shots from CF card in one directory (some dual-ISO CR2s, some normal CR2s) and I just want to throw them all at this script and let it sort them out for me. As an end result I want a directory that just contains the DNG/CR2 files that I'll be importing into Lightroom. If the dual-ISO CR2 files stay alongside the non-dual-ISO CR2 files as they currently do then I still have to filter through them manually.
Here's some code to do this. Put this up near the top of the script:
dim movecr2s,cr2targetdir
movecr2s=true 'whether to move the original dual-ISO CR2 files to another directory
cr2targetdir="Dual-ISO" 'the subdirectory to move the dual-ISO CR2 files into
...and put this before the if compressdng then check:
if movecr2s then
if not fso.FolderExists(mainfolder & "\" & cr2targetdir) then fso.createFolder(mainfolder & "\" & cr2targetdir)
' find any DNG files that were created and move the corresponding CR2 file
set files=mainfolder.Files
for Each file in files
if lcase(left(file.Name, len(imgprefix)))=lcase(imgprefix) and lcase(Right(file.Name, len(imgsuffix)))=lcase(".DNG") then
fso.MoveFile mainfolder & "\" & fso.GetBaseName(file) & imgsuffix, mainfolder & "\" & cr2targetdir & "\" & fso.GetBaseName(file) & imgsuffix
end if
next
end if
Note that this doesn't run in parallel like the rest of the script but I don't think there'll be any real performance gains from doing so anyway.
The one additional thing that I'd like to see but haven't tried implementing myself yet is to compress the DNG files in place, rather than have them end up in a different directory (so I'd end up with a single directory that I can import directly in to Lightroom).
chris_overseas
that is the feature which i wanted long time ago,
but could you please edit the script instead of giving a puzzle to us?
As far as I understand your guidance I am getting only:
"Invalid ´for´ loop control variable" code.
Quote from: orim on October 29, 2013, 10:03:28 PM
that is the feature which i wanted long time ago,
but could you please edit the script instead of giving a puzzle to us?
Sure. I'd intended for engardeknave to incorporate this into the original post hence why I just posted the changes, but here's a whole copy of the modified script for you. Note I haven't tested this exact version since my local version contains a few other changes that you probably won't want and which I quickly stripped out before pasting, hopefully that didn't introduce any problems:
'------------------------------------------------------------------
dim cr2hdrpath,cr2hdrexe
cr2hdrpath="E:\Photos\Utils"
cr2hdrexe="cr2hdr.exe"
dim imgprefix,imgsuffix 'used to identify the files we're processing
imgprefix=""
'imgprefix="DUAL"
imgsuffix=".CR2"
dim movecr2s,cr2targetdir 'whether to move the original CR2 files to another directory
movecr2s=true
cr2targetdir="Dual-ISO"
dim adngcpath,adngcexe,compressdng
compressdng=true
deleteoriginaldng=true
adngcpath="C:\Program Files (x86)\Adobe"
adngcexe="Adobe DNG Converter.exe"
adngcoutputdir="Compressed-DNG"
dim maxprocs,windowtype
maxprocs=4
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.
'------------------------------------------------------------------
dim inputfolder
if Wscript.Arguments.Count>0 then
inputfolder=Wscript.Arguments(0) 'command line
else
inputfolder=InputBox("Enter the path to the dual ISO shots.","Dual ISO Script")
if inputfolder="" then WScript.Quit
end if
dim objShell
set objShell=CreateObject("Wscript.Shell")
objShell.CurrentDirectory=cr2hdrpath 'no idea why it needs this
dim fso
set fso=CreateObject("Scripting.fileSystemObject")
dim mainfolder
set mainfolder=fso.GetFolder(inputfolder)
dim file,files,filecount
set files=mainfolder.Files
filecount=0
dim cr2dngqueue,adngcqueue,deldngqueue
set cr2dngqueue=CreateObject("System.Collections.ArrayList")
set adngcqueue=CreateObject("System.Collections.ArrayList")
set deldngqueue=CreateObject("System.Collections.ArrayList")
'"adobe dng converter.exe" -dng1.4 -cr7.1 -d "C:\test\output" "C:\test\img_9242.dng"
for Each file in files 'find applicable .CR2s
if lcase(left(file.Name, len(imgprefix)))=lcase(imgprefix) and lcase(Right(file.Name, len(imgsuffix)))=lcase(imgsuffix) then
cr2dngqueue.add """" & cr2hdrpath & "\" & cr2hdrexe & """ """ & file.Path & """"
if compressdng then
adngcqueue.add """" & adngcpath & "\" & adngcexe & """ -dng1.4 -cr7.1 -d """ & mainfolder & "\" & adngcoutputdir & """ """ & fso.GetParentFolderName(file) & "\" & fso.GetBaseName(file) & ".DNG"""
if deleteoriginaldng then deldngqueue.add "cmd.exe /c del """ & fso.GetParentFolderName(file) & "\" & fso.GetBaseName(file) & ".DNG"""
end if
filecount=filecount+1
end if
next
if filecount=0 then
msgbox "No files found! Check prefix and suffix."
else
runqueue cr2dngqueue,maxprocs,cr2hdrexe
if movecr2s then
if not fso.FolderExists(mainfolder & "\" & cr2targetdir) then fso.createFolder(mainfolder & "\" & cr2targetdir)
' find any DNG files that were created and move the corresponding CR2 file
set files=mainfolder.Files
for Each file in files
if lcase(left(file.Name, len(imgprefix)))=lcase(imgprefix) and lcase(Right(file.Name, len(imgsuffix)))=lcase(".DNG") then
fso.MoveFile mainfolder & "\" & fso.GetBaseName(file) & imgsuffix, mainfolder & "\" & cr2targetdir & "\" & fso.GetBaseName(file) & imgsuffix
end if
next
end if
if compressdng then
if not fso.FolderExists(mainfolder & "\" & adngcoutputdir) then fso.createFolder(mainfolder & "\" & adngcoutputdir)
runqueue adngcqueue,maxprocs,adngcexe
if deleteoriginaldng then runqueue deldngqueue,100,"zzzzzzzzzz" 'don't wait for cmd.exe, might be running for another reason
end if
msgbox "Finished " & filecount & " files."
end if
set cr2dngqueue=nothing
set adngcqueue=nothing
set deldngqueue=nothing
set fso=nothing
set objShell=nothing
set objfile=nothing
Set WshShell=nothing
sub runqueue(queue,instances,exename)
dim WshShell,myproc
Set WshShell=WScript.CreateObject("WScript.Shell")
dim line
for Each line in queue
waitfinish instances, exename
WshShell.Run line,windowtype,false
next
waitfinish 1,exename
end sub
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
' The Adobe DNG Converter supports the following command line options:
' -c Output compressed DNG files (default).
' -u Output uncompressed DNG files.
' -l Output linear DNG files.
' -e Embed original raw file inside DNG files.
' -p0 Set JPEG preview size to none.
' -p1 Set JPEG preview size to medium size (default).
' -p2 Set JPEG preview size to full size.
' -cr2.4 Set Camera Raw compatibility to 2.4 and later
' -cr4.1 Set Camera Raw compatibility to 4.1 and later
' -cr4.6 Set Camera Raw compatibility to 4.6 and later
' -cr5.4 Set Camera Raw compatibility to 5 .4 and later
' -dng1.1 Set DNG backward version to 1.1
' -dng1.3 Set DNG backward version to 1.3
' -d <directory> Output converted files to the specified directory. Default is the same directory as the input file.
' -o <filename> Specify the name of the output DNG file. Default is the name of the input file with the extension changed to ".dng".
perfect, thanks.
it works now as expected. :)
HaND!
Now it always puts the dualisos, compressed dngs, and regular cr2s in a folder. See the options.
This is awesome :D
Thanks for this
How to do this on a mac??
Maybe run a windows application and run the script from there?
I don't have a Mac. I'm sure there's a Mac solution somewhere here, though.
In the script, it seems that the command line wants an argument for the actual directory where the .cr2 files are. I use a command line of either
VbsScript S:\MyCr2Dir or
VbsScript .
Otherwise, the script prompts for a subdirectory.
Would it be ok to have a line in the script hear the top:
'------------------------------------------------------------------
cr2hdrpath="S:\MyCr2Dir"
inputfolder=cr2hdrpath
and then comment out lines that invoke the Open dialog?
' 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
Also:
'cr2hdrexe="cr2hdr.exe"
cr2hdrexe="cr2hdr-cmd.exe"
Just checking ... in the .vbs script, is the version with the filename cr2hdr-cmd.exe a modified version of the normal cr2hdr.exe, except with additional debugging options?
Also, I'm confused on what the following line does:
deleteoriginaldng=true
It doesn't seem to make any difference whether it is true or false.
The original .cr2's are still deleted, regardless, from the original directory with the cr2hdr.exe and .cr2 files:
cr2hdrpath="S:\MyCr2Dir"
That was unexpected.
The .cr2 files do seem to be preserved in the created subdirectories:
"Regular CR2s"
"Dual ISO CR2s"
So I guess that is fine.
Quote from: RenatoPhoto on September 26, 2013, 01:58:14 PM
Ok, I am vbs illiterate.
Is there a way to run the script at lower priority so it doesn't reduce the responsiveness of the foreground window?
such as a change to statement:
WshShell.Run line,windowtype,false
From the command line, you can use:
start /belownormal cr2hdr .....
Also, the script seems to remove Rating Stars and Label Colors that were in the .xml sidecar files. They were put there with Adobe Bride. I used Stars
and Labels to keep track of which files were in what category:
* 6d or 5d2
* Dual-ISO or non-Dual-ISO
* _MG or _UAL or _0
Is that "as expected"?
Updated, see options at the top of the script.
QuoteWould it be ok to have a line in the script hear the top
You could just do that and answer your own question. Nothing's going to explode if you edit it. The whole advantage of using this is that you can customize it. Anyway, there's a line where you can put your own input directory now.
Quoteis the version with the filename cr2hdr-cmd.exe a modified version of the normal cr2hdr.exe, except with additional debugging options
It's an old version.
Quotedeleteoriginaldng=true
This deleted the uncompressed dng, but it's no longer relevant.
QuoteIs there a way to run the script at lower priority
Reduce maxprocs.
QuoteAlso, the script seems to remove Rating Stars and Label Colors that were in the .xml sidecar files.
It doesn't move any .xml files. Run script first then edit.
Moar updates, see first post.
Thanks. Looks good.
Several minor revisions to consider:
dualisocr2dir="Dual ISO CR2s"
regularcr2dir="Regular CR2s"
dngoutputdir="Dual ISO DNG"
* Consider having dashes or underscores or CamelCase, instead of spaces in filenames
* Consider having plural DNG for consistency with plural CR2s
Here's what I use, with verbose hints to myself on what to do with them next:
dualisocr2dir="Dual-ISO_CR2s_ToArchive"
regularcr2dir="Regular_CR2s_ToProcessWithDngConverter"
dngcoutputdir="Dual-ISO_CR2s_2_Compressed_DNGs_Done"
* Consider having the variable for inputfolder up at the top with the variable for cr2hdrpath. I'd think the preferred default would be:
inputfolder=cr2hdrpath
Also, would it be possible to have an option for the script to proceed to process the "Regular CR2s" that were not Dual-ISO with DngConverter? Could that be the default?
FWIW: With my 2600k that has 4 cores and multi-threading, use of
maxprocs=7
instead of 8 procs
still pretty much pegs the Windows TaskManager cpu monitor, and makes the computer unresponsive.
I've been launching a Cmd window, setting its priority to BelowNormal, and then launching the .vbs script from that. That keeps the foreground window responsive instead of very sluggish. Am I doing something wrong?
QuoteAm I doing something wrong?
Yes.
Only tried on a few files but it should now correct green tint. Set exiftoolpath and correcttint in the options.
I really like your script.
But the newer Version doesnt work for me.
I have put the Script, the cr2hdr.exe and the exiftool.exe into the folder C:\cr2hdr\.
And change of course:
cr2hdrpath="C:\cr2hdr\"
and
exiftoolpath="C:\cr2hdr\"
But ifi run the script, it says "No DNG files created. Check script options and log.".
Started: 30.03.2014 19:11:48
Input folder is C:\Users\Pacman\Pictures\test
Searching for .CR2 files
Queued cmd.exe /c ""C:\cr2hdr\cr2hdr.exe" --compress "DUAL8298.CR2" > DUAL8298.CR2.log "
Queued C:\cr2hdr\exiftool.exe DUAL8298.dng -asshotneutral="0.473635 1.05 0.624" -overwrite_original
Converting Dual ISO .CR2 files
Executing: cmd.exe /c ""C:\cr2hdr\cr2hdr.exe" --compress "DUAL8298.CR2" > DUAL8298.CR2.log "
Running exiftool
No DNG files created. Check script options and log.
It seems, that the script ignore the Inputfolder.
Do you have any ideas?
Thanks
Ronald
P.S.: And one little other wish, i have.
Can you add your script a Versions Number. So i can see, if you change anyting.
Thanks a lot ;op
QuoteMake sure all paths end with a "\", ie. "C:\cr2hdr\"
Try adding a slash to the end of all paths. It should work fine with long paths too.
I also just updated it to remove the tint adjustment. (It won't work with most cameras, and is incompatible with the latest cr2hdr.) Also a couple of other bugs that would prevent it from working for anyone but me probably.
I'll just add a date to the top of the script.
Thanks for the quick answer.
The date at the top of the script is great :D.
But the Script doesnt work :(
It finds my CR2 Files, but doesnt do anything.
The DUAL8298.CR2.log looks like this.
cr2hdr: a post processing tool for Dual ISO images
Last update: d0ac769 on 2014-01-23 10:13:39 UTC by alex:
cr2hdr: experimental white level routine with two separate levels ...
Active options:
--amaze-edge : use a temporary demosaic step (AMaZE) followed by edge-directed interpolation (default)
--cs2x2 : apply 2x2 chroma smoothing in noisy and aliased areas (default)
--compress : Lossless DNG compression
Input file : DUAL8298.CR2
Camera : Canon EOS 5D Mark III
Full size : 0 x 0
Active area : 0 x 0
But i didnt have a 5D Mark III and the files size is not correct to.
If i put my test file into a other paths (C:\Test\) it doesnt work too.
The only way to make it work, is copy the cr2 into my working paths "C:\cr2hdr\".
i added of course a slash to the end of all paths.
Do you have any other ideas?
Thanks a lot
Ronald
Did you change the cr2hdr path in the script? Please check all the script options and make sure everything is set correctly. Also read all the directions above and comments in the script by all the settings. If you did all that, post your config (the top settings of the script).
Thanks for your help.
i dont see, what iam doing wrong.
Here is my config part:
'------------------------------------------------------------------
'last update: 3/30/2014
cr2hdrpath="C:\cr2hdr\" 'ends with a slash \
cr2hdrexe="cr2hdr.exe"
cr2hdrargs="--compress"
exiftoolpath="C:\cr2hdr\" '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.
'------------------------------------------------------------------
This part of the log Files is confusing me.
Executing: "C:\cr2hdr\cr2hdr.exe" --compress "DUAL8298.CR2"
Why i dont see my Paths there?
Started: 4/2/2014 2:35:34 AM
Input folder is C:\pictures
Searching for .CR2 files
Queued "C:\cr2hdr\cr2hdr.exe" --compress "IMG_7361.CR2"
Converting Dual ISO .CR2 files
Executing: "C:\cr2hdr\cr2hdr.exe" --compress "IMG_7361.CR2"
Moving Dual ISO .CR2 files
Created "C:\pictures\Dual ISO CR2"
Moving "C:\pictures\IMG_7361.CR2" to "C:\pictures\Dual ISO CR2\IMG_7361.CR2"
Moving any regular .CR2 files
Moving Dual ISO .DNG files
Created "C:\pictures\Dual ISO DNG"
Moving "C:\pictures\IMG_7361.DNG" to "C:\pictures\Dual ISO DNG\IMG_7361.DNG"
Moving log files
Processed 1 file(s). Converted 1 Dual ISO(s). Runtime: 19.61 seconds.
Created "C:\pictures\logs"
Just tried those folders and it works for me. It doesn't show the path at that point. Check to make sure that file is valid. Run cr2hdr on it from the command prompt manually.
There's also a couple other solutions to running multiple cr2hdrs in this section if you haven't tried them.
I have tested and i dont understand it :P.
In the folder C:\cr2hdr\ i have the "cr2hdr.exe" "dcraw.exe" "exiftool.exe" und your vbs script.
In the folder C:\Test\ i put a dual iso test image.
if i run the script in the folder C:\cr2hdr\ it doesnt work.
If i put the "cr2hdr.exe" "dcraw.exe" "exiftool.exe" files in the folder C:\Test\ too.
It works like a charm if i start the script in the folder C:\Test\. ???
The script works by running cr2hdr with the current directory set to the folder containing the images. This is because I couldn't cr2hdr to work correctly with paths and file names. The current directory is set at the line wshshell.currentdirectory=inputfolder. You can check if the current directory is properly set (to c:\test) with msgbox wshshell.currentdirectory. You also might try replacing the line wshshell.currentdirectory=inputfolder with wshshell.currentdirectory="c:\test".
Is there a way to change multiple_cr2hdr.vbs so that I can move the folder around and it will still work? By that I think I mean have all the extra files in the same directory as multiple_cr2hdr.vbs, and just drop CR2 files in the same directory and run it.
I think this requires setting the paths relative to multiple_cr2hdr.vbs script...
At the top:
inputfolder=left(wscript.scriptfullname,instrrev(wscript.scriptfullname,"\"))
And maybe comment out inputfolder=getfolder(...
Thanks so much!
For anyone else interested, you can change all of these, if desired:
cr2hdrpath=left(wscript.scriptfullname,instrrev(wscript.scriptfullname,"\"))
exiftoolpath=left(wscript.scriptfullname,instrrev(wscript.scriptfullname,"\"))
inputfolder=left(wscript.scriptfullname,instrrev(wscript.scriptfullname,"\"))
Works great for me. I just drop my Raw files in the same folder as the script and run the script. done!
thanks!
I'm also (especially) interested in having it work for .dng files as made from ML RAW dual-ISO video. It seems to only work for my CR2 stills...
I don't know how that works. I never use video, and I've actually since switched to Nikon. But you probably just need to make the script look for .dng files. Ie., see the line: ' if valfname(file.Name,".CR2") then ' and disable all the file organizing (organize=false).
I've starting playing with this and really wanted to be able to use the hyperthreading cores without losing UI or foreground program responsiveness.
I don't see a way to add a priority parameter when using wshshell.run directly. The start program does though, so I've modified the script to launch start, which starts cr2hdr with low priority. My I7 is remaining responsive with 8 processes going now.
The primary change is the cr2dngcmd variable assignment. I've left the original commented out. Window minimizing is now controlled by the start command's /MIN parameter.
This is the new command passed:
QuoteExecuting: C:\WINDOWS\system32\cmd.exe /c start "Processing _UAL2744.CR2" /MIN /LOW "G:\Photo_workspace\DualISO\cr2hdr.exe" --compress "_UAL2744.CR2"
G:\Photo_workspace\DualISO\ being my test folder
'------------------------------------------------------------------
'last update: 4/06/2017
'NOTE: a copy of dcraw.exe and exiftool.exe needs to be in the folder with the dual iso images
cr2hdrpath="G:\Photo_workspace\DualISO\" 'ends with a slash \
cr2hdrexe="cr2hdr.exe"
cr2hdrargs="--compress"
exiftoolpath="G:\Photo_workspace\DualISO\" 'ends with a slash \ Used for correcttint option
inputfolder="G:\Photo_workspace\" '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=8 '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.
'3 & 7 replaced by parameters /MAX or /MIN on the start command when setting the cr2dngcmd variable
'------------------------------------------------------------------
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
starttime=Timer
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="C:\WINDOWS\system32\cmd.exe /c start ""Processing " & file.name & """ /MIN /LOW " & """" & cr2hdrpath & cr2hdrexe & """ " & cr2hdrargs & " """ & file.name & """" 'no logs
'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
Hi guys,
Is there a way to make this useful with DNGs files (as from raw dualiso video)? May be modifying the .vbs (I don't know how to do it)...