View Full Version : free stuff
Benny Pedersen
July 8th, 2006, 08:39 PM
After I got me a Canon that shot RAW. I made some experiment the first days. Ex.: I shot both RAW+JPG at the same time. As a result of that experiments, (want to know my Camera...) I got double files JPG that I now want to delete but keep my RAW files. If you got into a similar task, I wrote this little VBS file. Double click it and it would mark out all JPGs in specified folder (not in subfolders) but for JPGs if RAW with same filename exists ONLY.
See line number 5 and 6, (5 to 7) below.
Benny Pedersen,
PS.: Im working on another little program, so you may comeback here later...
BTW. Im soon going on holidays to a biblecamp but I hope that I may be in time to upload that other program along with a Lesson2 about a usefull technique that I found in Photoshop Elements... :)
' if RAW file exists, rename JPG file
' Lines that begins with a single quote is comments that you can
' include in this VBS file. (the next line is line number 4)
option explicit
dim RawPath: RawPath= "D:\Fotos\Arkiv\100CANON\Wedding\RAW"
dim JpgPath: JpgPath= "D:\Fotos\Arkiv\100CANON\Wedding"
dim RawExt: RawExt= "Cr2"
dim JpgExt: JpgExt= "Jpg"
dim JpgFile, f, fso: set fso= createObject("scripting.fileSystemObject")
for each f in fso.getFolder(RawPath).files
if uCase(fso.getExtensionName(f)) = uCase(RawExt) then
JpgFile= JpgPath & "\" & fso.getBaseName(f) & "." & JpgExt
if fso.fileExists(JpgFile) then
JpgFile= fso.getFile(JpgFile)
fso.moveFile JpgFile,JpgFile & "." & JpgExt
end if
end if
next
set fso= nothing: msgBox "Done", 4096
GaryK
July 9th, 2006, 08:38 AM
Benny
Thanks for the hard work. Is this for cameras that take raw and jpg at the same time?
JonE
July 9th, 2006, 04:22 PM
Thanks for contributing this. Here's a non-programmer's version that I have used for similar situations:
1) Open one Explorer window and search the folder for files named *.jpg
2) Open another Explorer window and search the folder for files named *.raw [or *.nef or whatever your raw file extension is]
3) Line the two windows next to each other and resize as needed so the two file lists are right next to each other.
4) Compare lists and delete as needed.
Benny Pedersen
July 9th, 2006, 09:41 PM
GaryK: Is this for cameras that take raw and jpg at the same time?
Yes, but it could also be used if you have other same filenames with different extensions. The best way to figure out how it work, is to make copies of some few files into an empty folder(s), then experiment on that folder to see how and what... When done, just delete the test folder and all within it.
JonE: Agree, something like/or that way maybe the way to do such. The little program is written to avoid doing it that way, ofcause.
Another thing with the program is that it don't fail about a file that a human would/could delete without using the program... and its faster, but
the security thing should ofcause have the heighest priority :D
Benny
PS. The next little program that I plan to upload here is a program that sort out JPG files that is modified...
Benny Pedersen
July 10th, 2006, 05:44 PM
...SNIP...
PS. The next little program that I plan to upload here is a program that sort out JPG files that is modified...
Ok, here it is:
To test this program, you could copy ex. 5 pictures to an empty folder:
Two JPG files that has never been modified.
Two JPG files that you saved from Photoshop (Elements).
One JPG file that you saved for web.
Specify a valid path in line number 2, ex. "C:\Photos\test"
Benny Pedersen,
PS. You can use the not documented line number 5 to rename JPG files with the date and time it was shot/taken. The following program is written in 60 lines, and you could name it "RenModifiedJPG.VBS" or something like that, as long its filename ends with an extension, VBS
option explicit' Rename modified JPG files
dim JpgPath: JpgPath= "C:\Photos\test"
const Subfolders= false ' false: default | true: include JPGs in subfolders (JpgPath)
const Postfix = true ' true: default | false: prefix
const MarkShot = false ' false: default | true: not documented
dim ImgModi,ImgShot,meM,hrM,dyM,mhM,yrM,meS,hrS,dyS,mh S,yrS,Modi,Done: Done=0
dim NewName,Put,Shot,i,JpgFiles,JpgFile,f,fso: set fso= createObject("scripting.fileSystemObject")
dim info: info= "Modified": if MarkShot then info= "Shot"
JpgFile= GetFileList(JpgPath, Subfolders, ""): JpgFiles= split(JpgFile, "*")
for i = 0 to uBound(JpgFiles) -1
JpgFile= JpgFiles(i)
Shot= GetExif(JpgFile,25)
if Shot = "" then' no exif (modified)
if not MarkShot then
Put= "(" & info & ")"
NewName= trim(replace(fso.getBaseName(JpgFile), Put, ""))
if Postfix then
NewName= NewName & " " & Put
else NewName= Put & " " & NewName
end if
NewName= fso.getParentFolderName(JpgFile) & "\" & NewName & right(JpgFile,4)
Done= RenameFile(JpgFile, NewName, Done)
end if
else Modi= GetExif(JpgFile,3)
yrS=D2(year(Shot)):mhS=D2(month(Shot)):dyS=D2(day( Shot)):hrS=D2(hour(Shot)):meS=D2(minute(Shot))
yrM=D2(year(Modi)):mhM=D2(month(Modi)):dyM=D2(day( Modi)):hrM=D2(hour(Modi)):meM=D2(minute(Modi))
ImgShot= yrS & mhS & dyS &" "& hrS & meS: ImgModi= yrM & mhM & dyM &" "& hrM & meM
if MarkShot or ImgModi <> ImgShot then
Put= "(" & info & " " & ImgModi & ")": if MarkShot then Put= "(" & info & " " & ImgShot & ")"
NewName= trim(replace(fso.getBaseName(JpgFile), Put, ""))
if Postfix then
NewName= NewName & " " & Put
else NewName= Put & " " & NewName
end if
NewName= fso.getParentFolderName(JpgFile) & "\" & NewName & right(JpgFile,4)
Done= RenameFile(JpgFile, NewName, Done)
end if
end if
next: msgBox "Found (JPG)"& vbTab & uBound(JpgFiles) & vbLf _
& "Done:"& string(2,vbTab) & Done,4096,_
fso.getFilename(wScript.scriptFullName) &" by Benny Pedersen": set fso= nothing
function D2(byVal N): D2= right("00"& trim(N),2): end function
function GetFileList(P,Recurse,List): dim F
for each F in FSO.getFolder(P).files
if lCase(FSO.getExtensionName(F)) = "jpg" then List= List & F & "*"
next
if Recurse then
for each F in FSO.getFolder(P).subfolders: GetFileList F,Recurse,List
next
end if
GetFileList= List
end function
function RenameFile(byVal From, byVal T, byVal Done)
fso.moveFile From,T: RenameFile= Done +1
end function
function GetExif(byVal F,byVal N)
dim SAO: set SAO= createObject("shell.application")
dim oFld: set oFld= SAO.nameSpace(FSO.getParentFolderName(F))
GetExif= oFld.getDetailsOf(oFld.parseName(FSO.getFileName(F )),N)
end function
Benny Pedersen
July 10th, 2006, 08:47 PM
And here's a little acolyte in 56 lines :cool:
Benny Pedersen,
option explicit' RemoveBrackets.VBS
' Removes round brackets (along with brackets content) from "filename.JPG"
' Ex. A file long named:
' "(Shot 060527 1430) 0067 (Modified 060530 0720) (Modified 060531 2030).JPG"
' would become: "0067.JPG"
' In other words, you can undo what you did when you used the program "RenModifiedJPG.VBS"
' Or, if you just want to remove some text/part in brackets of a filename,
' Ex. "Img_768 (great sun).jpg" would simply become
' "Img_768.jpg"
'
' You can set the variable below named Subfolders TRUE instead of FALSE
dim JpgPath:JpgPath= "C:\photos\jpg\test"
const Subfolders = FALSE
dim OldName,NewName,Count,i,_
JpgFiles,JpgFile,fso: set fso= createObject("scripting.fileSystemObject")
JpgFile = GetFileList(JpgPath, Subfolders, ""): JpgFiles= split(JpgFile, "*")
for i = 0 to uBound(JpgFiles) -1
JpgFile= JpgFiles(i)
NewName= fso.getBaseName(JpgFile)
Count= 0
do: OldName= NewName
NewName= RemoveBrackets(OldName)
Count= Count +1
loop until OldName = NewName or Count > 8
NewName= fso.getParentFolderName(JpgFile) & "\" & NewName & right(JpgFile,4)
RenameFile JpgFile, NewName
next: msgBox "Found (JPG)"& vbTab & uBound(JpgFiles),4160,_
fso.getBaseName(wScript.scriptFullName) &" by Benny Pedersen": set fso= nothing
function RemoveBrackets(byVal NameBase)
dim A, B: A= 0: B= A
A= cInt(inStr(NameBase,"("))
if cBool(A) then
B= cInt(inStr(A,NameBase,")"))
if B > A then NameBase= left(NameBase,A-1) & mid(NameBase,B+1)
end if
RemoveBrackets= trim(NameBase)
end function
function GetFileList(P,Recurse,List): dim F
for each F in FSO.getFolder(P).files
if lCase(FSO.getExtensionName(F)) = "jpg" then List= List & F & "*"
next
if Recurse then
for each F in FSO.getFolder(P).subfolders: GetFileList F,Recurse,List
next
end if
GetFileList= List
end function
sub RenameFile(byVal From, byVal T)
' msgBox From & vbLf & T, 4096, Count
on error resume next: fso.moveFile From,T
on error goto 0
end sub
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.