In R I get Error in path.expand(path) : invalid 'path' argument

Started by R Soul, January 19, 2019, 07:29:00 AM

Previous topic - Next topic

R Soul

Hi,
Probably a really embarrassing newbie problem, but it has been doing my head in for a few hours....

In R I am trying to read tags of my entire music library (to try and identify duplicate files)


setwd("D:/Music/iTunes Music/")
files <- list.files(recursive=TRUE,pattern="*.mp3")
f<-as.data.table(files)
f<-f[!grep("\\?",files),]
f[,files:=paste("D:/Music/iTunes Music/",files,sep="")]
tags<-read_exif(f, tags=c("filename","Album"))


I end up getting a "Error in path.expand(path) : invalid 'path' argument"

I have tried all sorts of variants - the grep is in the above code as it looked at one point as though question marks in file names were the problem, but I can't seem to get the code correct.

If in the list files I use full.names=TRUE, I then get a ./ at the start of the name and this doesn't seem to help - I have tried to many other variants to list cleanly here.

the files column in f comes out looking like this:
                                                                                          files
    1:                    D:/Music/iTunes Music/(Pink Floyd)/Dark Side of the Moon/Us And Them.mp3
    2:         D:/Music/iTunes Music/[EFA MIXPLATE 1A] Dub Syndicat/Unknown Album/Is God A Man.mp3
    3:           D:/Music/iTunes Music/[EFA MIXPLATE 1B] Dub Syndicat/Unknown Album/Not A Word.mp3
    4:     D:/Music/iTunes Music/[EFA MIXPLATE 2A1] Dub Syndica/Unknown Album/Higher Than High.mp3....

So that all looks sensible to me...
and running

tags<-read_exif("D:/Music/iTunes Music/(Pink Floyd)/Dark Side of the Moon/Us And Them.mp3", tags=c("filename","Album"))

seems to work and produces
# A tibble: 1 x 3
  SourceFile                                                               FileName        Album               
* <chr>                                                                    <chr>           <chr>               
1 D:/Music/iTunes Music/(Pink Floyd)/Dark Side of the Moon/Us And Them.mp3 Us And Them.mp3 Dark Side of the Moon

So that is all good.
But it just won't work on a list of files across many directories

Any help much appreciated.
Thanks,
Tim



R Soul

So I wondered if it might be a character problem as there were no quotation marks in the f$files so I tried
tags<-read_exif(as.character(f[1,]), tags=c("filename","Album"))

which worked

But then I tried
> tags<-read_exif(as.character(f), tags=c("filename","Album"))
and got
Error in dir.exists(path) :
  file name conversion problem -- name too long?

and
> tags<-read_exif(as.character(f[1:10,]), tags=c("filename","Album"))
Error in read_exif(as.character(f[1:10, ]), tags = c("filename", "Album")) :
  Did you mean recursive = TRUE? The following files are missing (or are not files): c("D:/Music/iTunes Music/(Pink Floyd)/Dark Side of the Moon/Us And Them.mp3", "D:/Music/iTunes Music/[EFA MIXPLATE 1A] Dub Syndicat/Unknown Album/Is God A Man.mp3", "D:/Music/iTunes Music/[EFA MIXPLATE 1B] Dub Syndicat/Unknown Album/Not A Word.mp3", "D:/Music/iTunes Music/[EFA MIXPLATE 2A1] Dub Syndica/Unknown Album/Higher Than High.mp3", "D:/Music/iTunes Music/[EFA MIXPLATE 2A2] Dub Syndica/Unknown Album/Higher Than High Dub.mp3", "D:/Music/iTunes Music/[EFA MIXPLATE 2B1] Dub Syndica/Unknown Album/Breath Of Fresh Air Version.mp3",
"D:/Music/iTunes Music/_Amy Winehouse/_Back To Black/_He Can Only Hold Her.mp3", "D:/Music/iTunes Music/_Amy Winehouse/_Back To Black/_Just Friends.mp3", "D:/Music/iTunes Music/_Amy Winehouse/_Back To Black/_Love Is A Losing Game.mp3", "D:/Music/iTunes Music/_Amy Winehouse/_Back To Black/Me And Mr Jones.mp3")

So I am no better off?

Phil Harvey

This definitely isn't an ExifTool newbie problem.  This is an R question.  I think you should try asking in an R forum.

- 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 ($).

R Soul

Oh, OK - it just seems as though the error was comin gfrom me not understanding the reuired path in the read_exif command (which I thought was part of the exif tool?

StarGeek

Quote from: R Soul on January 19, 2019, 11:04:17 AMthe read_exif command (which I thought was part of the exif tool?

There appears to be at least one R package which calls exiftool (exifr), but that was created and maintained by someone else.

Searching around for that error, I see a lot of hits on Google, but nothing seems to stand out as a solution.  As Phil says, you're better off checking an R forum for help.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype