'Get all the JPG in a folder & create Thumbnails

Set fso = CreateObject("Scripting.FileSystemObject")
myFolder = ""
' Input via Arguments
If WScript.Arguments.Count > 0 then
	If fso.FolderExists(WScript.Arguments.Item(0)) Then 
		myFolder = WScript.Arguments.Item(0)
	Else
		If fso.FileExists(WScript.Arguments.Item(0)) Then
			myFolder = fso.GetParentFolderName(WScript.Arguments.Item(0))
		End If
	End If
End if
'Input via Explorer
If myFolder = "" Then 
	Set SA = CreateObject("Shell.Application")
	Set f = SA.BrowseForFolder(0, "Choose a folder", 0)
	If (Not f Is Nothing) Then
		myFolder =  f.Items.Item.Path
	End If
End If

If myFolder <> "" Then
	Set FSO = CreateObject("Scripting.FileSystemObject")
	Call ShowSubFolders(FSO.GetFolder(myFolder))
	msgbox "All Done"
End If

'Loop through all the files in the folder
Sub ProcFolder(dFolder)
	For each File in dFolder.Files
		If Ucase(Right(File.Path,4)) = ".JPG" then 
			If InStr(Ucase(File.Name), "FRONT") <> 0 then
				FSO.CopyFile File, File.ParentFolder & "\folder.jpg", true
			End If 
		End If
	Next
End Sub

'Recursively loop through all folders 
Sub ShowSubFolders(Folder)
    For Each Subfolder in Folder.SubFolders
        Call ProcFolder(Subfolder)'  <- Action here
        Call ShowSubFolders(Subfolder)
    Next
End Sub

