Public Function CreateText(ClientFld As String, ClientFld2 As String, tWidth As Integer, tHight As Integer)
Dim ImgScript As TextStream
Dim fso As Variant
Dim batPath As String: batPath = "C:\DB_Data\Data\"
Dim rSize As String
Dim paSSrKey As String
Set fso = CreateObject("Scripting.FileSystemObject")
Set ImgScript = fso.CreateTextFile("C:\DB_Data\Data\Images.bat", True)
Const Q As String * 1 = """"
ClientFld = Q & ClientFld & "%%i"""
rSize = tWidth & "x" & tHight
Call GetRegKeyImgMagic(paSSrKey)
ImgScript.WriteLine "@ECHO OFF"
ImgScript.WriteLine ""
ImgScript.WriteLine "set resizeSize=" & rSize
ImgScript.WriteLine "set convert_exe=" & Q & paSSrKey & Q
ImgScript.WriteLine "set foldername=" & Q & ClientFld2 & Q
ImgScript.WriteLine ""
ImgScript.WriteLine ""
ImgScript.WriteLine "IF NOT EXIST ""%convert_exe%"" ("
ImgScript.WriteLine " echo ImageMagick path is incorrect. You need to set it up in batch file!"
ImgScript.WriteLine " echo Current value: %convert_exe%"
ImgScript.WriteLine " pause"
ImgScript.WriteLine " exit 4"
ImgScript.WriteLine " )"
ImgScript.WriteLine ""
ImgScript.WriteLine "echo Resizing JPG files in %foldername%:"
ImgScript.WriteLine ""
ImgScript.WriteLine "chdir /D %foldername%"
ImgScript.WriteLine "set tmpCnt=0"
ImgScript.WriteLine "for /F ""usebackq delims="" %%i in (`dir /a:-d /b %foldername%\*.jpg`) do ("
ImgScript.WriteLine " set /a tmpCnt+=1"
ImgScript.WriteLine " call echo Proceed file %%tmpCnt%% from %%dirCnt%%: ""%%i"""
ImgScript.WriteLine ""
ImgScript.WriteLine """%convert_exe%"" ""%%i"" -resize %resizeSize% -quality 95" & " " & ClientFld
ImgScript.WriteLine " )"
ImgScript.WriteLine ""
ImgScript.WriteLine "echo """""
ImgScript.WriteLine "echo Resizing is done, check folder web for results!"
ImgScript.WriteLine "echo """""
ImgScript.WriteLine "EXIT"
Call shell(Environ$("COMSPEC") & " /c " & batPath & "\Images.bat", vbNormalFocus)
End Function