Error: cannot find Exiftool

1,352 views
Skip to first unread message

John Huang

unread,
Oct 3, 2018, 12:18:54 PM10/3/18
to camtrapR
I've been having trouble using the imageRename function, every time I run it I end up with the error:cannot find Exiftool. My files are being ran through a external hard drive, and the exiftool is on my C drive in my desktop. From the first couple of functions, it looks like R is able to find the exiftool so I am not quite sure what the problem is.

Here is the code that I currently have in Rstudio:

rm(list = ls())

library(camtrapR)


#make R find exiftool
exiftool_dir<-"C:/Windows/Exiftool/exiftool.exe"      
exiftoolPath(exiftoolDir = exiftool_dir)

#check to make sure it has been added to PATH
grepl(exiftool_dir,  Sys.getenv("PATH"))

#Loads my Camera Trap Trial Data
TrialData <- read.csv("Camera Trap Trial Run.csv")
#station: a station is a locality containing one or more camera traps (often a pair of two)
#camera trap: refers to the individual camera unit. One or more (often two) constitute a station
#occasion: a distinct sampling event of 1 or more days
#effort: number of active trapping days per station and occasion

#Creates the folders and the directory for the images
wd_createStationDir <- file.path("F:\\Camera Trap Trial", "Raw_Images")
StationFolderCreate1 <- createStationFolders(inDir = wd_createStationDir,
                                             stations = as.character(TrialData$Station),
                                             createinDir = TRUE)

StationFolderCreate1
#destination for renamed images to be copied to
wd_images_ID <- "F:\\Camera Trap Trial/Raw Images"
wd_images_raw_renamed <- file.path("F:\\Camera Trap Trial", "Renamed Images"


renamed <- imageRename(inDir = wd_createStationDir,
                       outDir = wd_images_raw_renamed,
                       hasCameraFolders = TRUE,
                       keepCameraSubfolders = TRUE,
                       copyImages = FALSE,
                       writecsv = TRUE)

Melissa S

unread,
Dec 7, 2018, 10:05:18 PM12/7/18
to camtrapR
I am having the same problem. Everything works until this:

exiftool_dir <- "C:/exiftool"
exiftoolPath(exiftoolDir = exiftool_dir)
# check if it has been added to PATH
grepl(exiftool_dir, Sys.getenv("PATH"))
[1] TRUE
renaming.table2 <- imageRename(inDir               = tagged_images,
+                                outDir              = tagged_images_renamed,       
+                                hasCameraFolders    = FALSE,
+                                copyImages          = TRUE
+ )
Error: cannot find ExifTool

Juergen Niedballa

unread,
Dec 12, 2018, 7:15:52 AM12/12/18
to camtrapR
Dear John and Melissa,
an alternative way to test if R can find exiftool is to run:

system("exiftool")

If R can find exiftool, you should see the exiftool documentation in your console (basically, a lot of text).

Regarding Johns qustion, exiftool is in "C:/Windows/Exiftool/exiftool.exe" ? If so, try

exiftool_dir<-"C:/Windows/Exiftool"      
exiftoolPath(exiftoolDir = exiftool_dir)

Argument exiftoolDir is meant to point to the directory containing exiftool.exe, not the file itself.
Alternatively, put the exiftool file in "C:/Windows", i.e. "C:/Windows/exiftool.exe"

Melissa, you could try the same to see if it helps.
Best,
Jürgen

kahindi ziro

unread,
Apr 27, 2019, 2:44:35 AM4/27/19
to camtrapR
hi
Was this problem solved. am kind of running in to the same problem a year down the line. and the suggested solution does not work

I replicated the code with the solutions but still getting same error

setwd("C:/Users/arken/Documents/MEGAsync/cam_trap")


library(camtrapR)



#Loads my Camera Trap Trial Data
camdata <- read.csv("CamData.csv")
#station: a station is a locality containing one or more camera traps (often a pair of two)
#camera trap: refers to the individual camera unit. One or more (often two) constitute a station
#occasion: a distinct sampling event of 1 or more days
#effort: number of active trapping days per station and occasion

#Creates the folders and the directory for the images

wd_createStationDir <- file.path("C:/Users/arken/Documents/MEGAsync/cam_trap","Raw_Images")
StationFolderCreate1 <- createStationFolders(inDir = wd_createStationDir,
                                             stations = as.character(camdata$Station),
                                             createinDir = TRUE)

StationFolderCreate1


#make R find exiftool
exiftool_dir<-"C:/Program Files/R/R-3.5.3"       
exiftoolPath(exiftoolDir = exiftool_dir)

#check to make sure it has been added to PATH
grepl(exiftool_dir,  Sys.getenv("PATH"))

#destination for renamed images to be copied to
wd_images_ID <- "C:/Users/arken/Documents/MEGAsync/cam_trap/Raw_Images"
wd_images_raw_renamed <- file.path("C:/Users/arken/Documents/MEGAsync/cam_trap", "Renamed Images")
                                   
                                   
                                   renamed <- imageRename(inDir = wd_createStationDir,
                                                          outDir = wd_images_raw_renamed,
                                                          hasCameraFolders = FALSE,
                                                          keepCameraSubfolders = FALSE,
                                                          copyImages = TRUE,
                                                          writecsv = TRUE)
                                   

Juergen Niedballa

unread,
Apr 27, 2019, 3:05:12 AM4/27/19
to camtrapR

Hi,

where did you save exiftool.exe? I'd suggest C:/Windows. Then you don't need to deal with exiftoolPath at all. Or any other directory returned by Sys.getenv("PATH").

Otherwise, please share the full path to exiftool.exe.
Thank you!
Jürgen

Juergen Niedballa

unread,
Apr 27, 2019, 3:45:42 AM4/27/19
to camtrapR
Thanks for the screenshot. I believe the problem is Windows hiding file extensions of known files. It is the default, but can cause problems and is unsafe too.

Follow the instructions here to show file extensions of known file types (the box highlighted in red at the bottom):

Then I believe you'll see that because of this behaviour of Windows, you accidentally renamed the file to 

exiftool.exe.exe

If so, rename to exiftool.exe and you should be good.
Jürgen

Megan Grant

unread,
May 28, 2024, 2:43:18 AMMay 28
to camtrapR
Hi  Jürgen, 

I know that this is an old post, but I am having the same issues. 

I have tried all the suggested solutions mentioned above and have had no luck:

- I have saved exiftool.exe to C:/Windows

- I checked to see if Windows was hiding file extensions following your instructions and link from 27 April

- When I run:
> system("exiftool")
I get the following output:
[1] 127

- I tried downloading exiftool directly from the website (https://exiftool.org/install.html) and in R using install_exiftool in the package exiftoolr

- The file is not zipped

- I've also looked at other blogs where people have had similar issues and nothing seems to work (https://github.com/JoshOBrien/exiftoolr/issues/1)

I'm not really sure what else to try at this point. I'm using R Version 4.4.0, and RStudio version 2024.04.01
Here's my code:
# Set working directory
setwd("C:/Users/mlgrant/Documents/Camera Traps")

# Load packages
library(camtrapR)
library(exiftoolr)

### Rename images to keep original images untouched
# Tell R which images are the raw images, not to be touched
wd_images_raw_TEST <- ("C:/Users/mlgrant/Documents/Camera Traps/Test")
# Tell R the directory for the images to be copied into
wd_images_raw_renamed_TEST <- ("C:/Users/mlgrant/Documents/Camera Traps/TestCopy")
# Rename images
renaming.table <- imageRename(inDir = wd_images_raw_TEST,
                              outDir = wd_images_raw_renamed_TEST,

                              hasCameraFolders = TRUE,
                              keepCameraSubfolders = TRUE,
                              copyImages = TRUE)

Any help will be hugely appreciated!
Thanks, 
Megan

Juergen Niedballa

unread,
May 28, 2024, 2:59:59 AMMay 28
to camtrapR
Hi Megan,
error 127 means that the system call cannot find exiftool in the PATH variables (that's where it looks for a executable files).
So you need to make sure that R / your system has the folder containing exiftool.exe in its PATH variables. 
You can check which directories are in PATH via:
Sys.getenv("PATH")

The easiest way to add a folder to PATH from within R is via camtrapR's addToPath() function (previously called exiftoolPath):
addToPath("C:/PATH/TO/EXIFTOOL")

Afterwards the system should be able to find exiftool.exe in the folder C:/PATH/TO/EXIFTOOL

Please also see the section "ExifTool for Windows" in vignette 1:
(note, I didn't update the vignette and it still contains the old function name exiftoolPath() instead of addToPath())

Best regards,
Jürgen

Megan Grant

unread,
Jun 2, 2024, 6:58:48 PMJun 2
to camtrapR
Many thanks for your reply,  Jürgen. That worked!
Reply all
Reply to author
Forward
0 new messages