newscript
' 2023-03-22
' DISCLAIMER: I have no connection with the open-source program ExifTool used for reading,
' writing and changing the EXIF data stored in some media file types,
' except that I have a copy of the tool, and have used a limited
' subset of it's capabilities.
' I expect that one day I will use my PWB MetaTagger application
' and export its tag info to the target files using the ExifTool.
'
' Here is an example of how to invoke EXIF from PlodWare Basic.
' This example extracts all the EXIF info from the files in the source folder
' and outputs them in comma separated variable (csv) file format.
dim cmdParams
' path/filename of exif executable parameters path of folder with images path/filename of output file
cmdparams = "C:\Users\george\Desktop\exif\exiftool.exe -csv -r -all ""C:\Users\george\Desktop\20 sorted\2022"" > ""C:\Users\george\Desktop\20 sorted\exif.csv"" "
system ( cmdParams)
' -----------------------------------------------
' The following has the same effect as the above example
' but has better/safer handling of paths with embedded spaces,
' and shows how the ExitTool output can be placed in a databank.
newscript
' embedded spaces in a path cause problems when passed to SYSTEM
Function HandleSpaceInPath ( path )
HandleSpaceInPath = "\"" & path & "\" "
end Function
' purely for visibility, I have separated the command in to sections
dim ExecutableFile = "C:\Users\george\Desktop\exif\exiftool.exe"
dim Parameters = " -csv -r -all "
dim ImagesPath = "C:\Users\george\Desktop\20 sorted\2022"
dim OutPutRedirection = " > "
dim outPutFile = "C:\Users\george\Desktop\20 sorted\exif5.csv"
' then put the sections together
dim cmdLine = ""
cmdLine = cmdLine & HandleSpaceInPath ( ExecutableFile )
cmdLine = cmdLine & " " & Parameters
cmdLine = cmdLine & " " & HandleSpaceInPath ( ImagesPath )
cmdLine = cmdLine & " " & OutPutRedirection
cmdLine = cmdLine & " " & HandleSpaceInPath ( outPutFile )
' the following is essential IF the FIRST section is enclosed in double quotes
' which it is in this example!
cmdLine = "\"" & cmdLine & "\""
report ( cmdLine)
' WARNING; this can take time
' During this time a black, empty, command line window is visible
' in my tests, ~ 30,000 files took about 10-15 minutes
' The more file types scanned, the potentially more columns generated
' in my tests, the ~ 30,000 files, returned 996 columns!
' About 12 rows contained the NULL character, I do not know if this should be handled by ExifTool
' so I have modified my CSV reader to replace NULL by SPACE
system ( cmdLine)
' the following would have worked just as well, but is harder to understand
system ( " """"C:\Users\george\Desktop\exif\exiftool.exe"" -csv -r -all ""C:\Users\george\Desktop\20 sorted\2022"" > ""C:\Users\george\Desktop\20 sorted\exif5.csv"" "" " )
' -----------------------------------------------
' send the CSV to a table named exifData
' define the name ofthe target
dim exifTable = "exifData"
' ensure that there is an open DB
if ( ! isdbOpen ) then
dbOpen ("memory")
END IF
' ensure that the target table does not already exist
sql ( " drop table if exists " & exifTable )
' read in the CSV file to a database
CSVread ( outPutFile , ,exifTable )
' -----------------------------------------------