Using ExifTool from Shell

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
IanMcK
Posts: 16
Joined: Mon Jul 05, 2010 10:47 am

Using ExifTool from Shell

Post by IanMcK » Sun Jun 04, 2017 3:38 pm

Hi

I want to access the metaData contained in a number of jpgs (paths1.jpg; paths2.jpg; paths3.jpg etc) that I have - camera info, title, decription etc so that I can manipulate the data with LC
I have installed exifTool in c:\Windows directory
and have tested the following from terminal

exiftool -t -sep = "D:\IanM\Documents\My LiveCode Archive\ImageData\Images\paths2.jpg" >> "D:\IanM\Documents\My LiveCode Archive\ImageData\Images\exifJpegData.txt"

However when I construct this same command in LC I get
Execution Error at line 22 (Handler: can't find handler) near WindowShell, char 1

Here is my code

Code: Select all

on mouseUp
   put the long name of this stack into tFolderName
   delete word 1 of tFolderName -- remove 'stack' from folder name
   put the value of tFolderName into tFolderName -- remove quote marks
   set itemdelimiter to "/"
   put "Images"  into item -1 of tFolderName -- append target folder name
   put files(tFolderName) into tFileList -- get the file list
   put tFileList into tJPegs
   Filter lines of tJPegs with regex pattern "jpg"
   sort lines of tJPegs ascending numeric -- sorted list of jPegs
   
   put the defaultfolder into tOldDefaultFolder -- save the current default
   set the defaultFolder to tFolderName
   
   put "-t -sep =" into tTags  -- tab delimited list with = as separator
   put tFolderName&"/"&"JPegExifData.txt" into tJPegExifFileName  -- output file is same dir as jPegs
   
   repeat for each line tImage in tJPegs
      put tFolderName&"/"&tImage into tJpegName 
      put "C:/Windows/exifTool" &space&tTags &space&quote& tJpegName &quote &space& ">>" &space&quote&tJPegExifFileName &quote into tExifCmdLine
      
      WindowShell(tExifCmdLine)  --- Execution stops at this line <--------------------------------
      put tImage&": "& the result&cr after msg  -- check the result
   end repeat
   
   set the defaultFolder to tOldDefaultFolder -- restore the default
end mouseUp

function windowshell pCmd
   replace "/" with "\" in pCmd
   return shell(pCmd)
end windowshell
I have also tried using just "exiftool" rather than "C:/Windows/exiftool",
both "/" and "\" in the file path, changing, and NOT changing, the default folder
and appending .exe to exiftool - all with the same result.

There must be someting wrong in the way that I am calling exiftool as it works perfectly in terminal.
Can anyone shed some light please?
Any advice would be really appreciated.

Thanks

Klaus
Posts: 14206
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Using ExifTool from Shell

Post by Klaus » Sun Jun 04, 2017 3:50 pm

Hi Ian,

your "WindowsShell" is a FUNCTION! :D

Do this:
...
## WindowShell(tExifCmdLine)
get shell(tExifCmdLine)
...

Best

Klaus

IanMcK
Posts: 16
Joined: Mon Jul 05, 2010 10:47 am

Re: Using ExifTool from Shell

Post by IanMcK » Sun Jun 04, 2017 4:01 pm

Hi Klaus
Thank you very much for your very quick reply.
Yes that did it! I have to say that I'm more that a bit embarrassed to have made such a simple, basic error! Just overthinking the problem I guess.

regards

IanM

Post Reply