Identify and Convert using VB Script
Posted: 2016-08-04T08:14:55-07:00
I am not sure if Imagemagick can do this or not. I have been unsuccessful so far.
I would like to be able to do the following:
1. Search for files with the file extension of .tif and file size is greater than 0. - This step is done and working
2. If found I need to identify the actual MIME type of the file. We have an export program that is exporting as TIF files when the actual file type is JPEG.
3. If the file MIME type is JPEG, rename the file to .jpg
4. Move onto the next file
I would like to see the output of the identify so the rest can be done with vbscript since an extension rename is all that is needed. The MIME type is already JPEG but the file has and extension of TIF
Currently, I cannot return the results of the identify when I call it thru a command line. When I use a direct call to identify as shown below I get an error.
identity: 400: Perform: Unsupported argument type.
Thoughts, options? Any help is appreciated.
I would like to be able to do the following:
1. Search for files with the file extension of .tif and file size is greater than 0. - This step is done and working
2. If found I need to identify the actual MIME type of the file. We have an export program that is exporting as TIF files when the actual file type is JPEG.
3. If the file MIME type is JPEG, rename the file to .jpg
4. Move onto the next file
I would like to see the output of the identify so the rest can be done with vbscript since an extension rename is all that is needed. The MIME type is already JPEG but the file has and extension of TIF
Currently, I cannot return the results of the identify when I call it thru a command line. When I use a direct call to identify as shown below I get an error.
identity: 400: Perform: Unsupported argument type.
Thoughts, options? Any help is appreciated.
Code: Select all
Option Explicit
Dim objFSO, objRegEx, objShell, imageMagick
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objRegEx = CreateObject("Vbscript.RegExp")
Set objShell = CreateObject("Wscript.Shell")
Set imageMagick = CreateObject("ImageMagickObject.MagickImage.1")
Dim strPost
strPost = "ExportBug"
Dim objFolder, colFiles, objFile
Dim Result
Set objFolder = objFSO.GetFolder(strPost)
Set colFiles = objFolder.Files
For Each objFile in colFiles
If LCase(objFSO.GetExtensionName(objFile.Name)) = "tif" and objFile.size > 0 Then
MsgBox objFile.name
Result = imageMagick.identify(objFile)
MsgBox Result
End If
Next
Set objFolder = Nothing
Set colFiles = Nothing