using exiftool with vba shell command

Started by mjglackin, June 01, 2015, 06:11:45 PM

Previous topic - Next topic

mjglackin

Hello Phil,

Thanks for the excellent program.  I have no trouble getting it to work from Windows cmd prompt.  But, when I use the VBA shell command, I could not get the redirection ">" to work, except once!  And, given that I've been playing with it all weekend, I don't know how I stumbled upon it. 

The redirection worked by appending the outfile "trashout.txt", to the file name "IMG0520".  So, somehow I managed to get the -a output stored in IMG_0520trashout.txt.  Any ideas on how I got there?

Michael

Phil Harvey

Hi Michael,

Without seeing either your command or your VBA code, I'd be shooting in the dark.  (I mean, I am a magician, but even I have my limitations.)

Even with these, I've never used the VBA shell command so I don't know how much help I would be.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

mjglackin

I'll keep hacking away at it.  Somewhere, in the -w!, -o, -?, & chr(34), "",|, cat,  > or >> I managed to get a redirect out of the VBA shell.  Now that I know I did it, it's just a matter of trying everything again.

However, one of your posts puts the information directly into the Excel sheet, which was the ultimate goal.  I'll be working on that today and tomorrow.  Then, its back to the academic exercise of redirecting through VBA shell.  If/when I succeed again, I will post the solution.

The last saved version of the VBA had  ans = shell(exif_path,vbmaximumfocus) where 

exif_path = "C:\Users\Michael\Desktop\exiftool.exe -a C:\Users\Michael\Desktop\IMG_0520.jpg -w trashout1.txt".

This did not work, of course.  Nor did -o trashout.txt, -w! trashout.txt, etc. 

Whatever worked used the file name without the jpg extension and appended the "trashout.txt" to the filename. 

The ultimate goal is to identify photos that I take every day by the address.  I am a roofer, and I work on 3-5 roofs per day, and I take about 80-100 photos each week.  Using Google Place ID, I can add a column to the spreadsheet with the Place ID, Longitude and Latitude.  With the Longitude and latitude from the meta data of the photos, I can convert to decimal, round up, and rename the directory as the customer's address.  From there, I can hyperlink the directory of photos to the customer sheet.  Currently, I have thousands of photos in files based on the transfer date from the camera. 

Yes, I should have stayed in school, and learned this stuff!  Instead, I dropped out and married early.  Now I fix other people's roofs instead of programming other people's solutions.  I got rid of the wife, but I still have the problem with VBA.  Alcohol helps with one of the problems.  Maybe more alcohol will help with both problems.

Michael

Phil Harvey

Hi Michael,

Quote from: mjglackin on June 01, 2015, 08:08:10 PM
exif_path = "C:\Users\Michael\Desktop\exiftool.exe -a C:\Users\Michael\Desktop\IMG_0520.jpg -w trashout1.txt".

This is why you got an output file of the form FILEtrashout1.txt.  The -w option specifies an extension for the output text file name.  See the -w option documentation for details.

I suspect that you never got redirection to work, and that it was -w that gave you the output file.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

PaulS

I had the same problem but I think there is a solution by doing the job in two steps

Set up the first  statement as follows:
exifpath = "c:\Windows\exiftool " + """filelocation&name""" + " -w A.txt"

where filelocation&name is the full location of the file & includes the name of the file with the suffix e.g. d:\Photos\building.jpg

The text file written then appears in the original directory as follows: d:\Photos\buildingA.txt

The final step is to rename the file if so required - perhaps back the building.txt

perhaps mjglacklin can be advised ( I am new to using a forum so do not know how)

P.S. Thanks for an excellent program