I have plenty of zip files and I want to load only the ones that met the name condition for example, unzip any file that has a name like this "Query Transaction History_20221122" I was able to achieve that with the script below
zip_files <-list.files(path ="C:/Users/Guest 1/Downloads",
pattern =".*Query Transaction History_20221122.*zip",full.names = TRUE )
Now I want to extract to the specified folder with the code below using the plyr package
ldply(.data = zip_files,.fun = unzip,exdir =my_dir )
and it extracts fine to the specified folder with no issue
The problem now is that the name of the folder is alphanumeric, which means that it comes with a name and also a date that is formatted as numeric please see the sample below
Query Transaction History_20221122
since it's something I will keep doing on a daily basis, I want to write a code that periodically changes the numeric part of the zip file name.
I tried using glue from the glue package see the sample below
checks<-format(Sys.Date(),"%Y%m%d")
zip_files <-list.files(path ="C:/Users/Guest 1/Downloads",
pattern =glue(".*Query Transaction History_{checks}.*zip",full.names = TRUE ))
it run fine but when I tried to extract the file using the second script
ldply(.data = zip_files,.fun = unzip,exdir =my_dir )
it then returned the error below
In addition: Warning message:
In FUN(X[[i]], ...) : error 1 in extracting from zip file
Kindly assist Thank you