I have a hard drive with thousands of images from a camera-trap proyect. I've used a software that detects in which photos there is an animal. From that I've got a .csv with one column per photo "tagged" with the full directory of each photo
| Column A |
| -------- |
| E:\Imagenes\2-1\VK1050_01\VK1050_01_1\**MFDC0421.JPG** |
| E:\Imagenes\2-1\VK1050_01\VK1050_01_1\MFDC0422.JPG |
.....
| E:\Imagenes\2-1\UJ8090_01\UJ8090_01_1\**MFDC0421.JPG** |
The source hard drive have several folders and subfolders (season, site, etc), that I would like to keep (but with only the tagged fotos from the list inside) Note that as the photos come from diferent cameras the photos names are the same sometimes, but in different folders.
For that I'm using the following code in R:
tagged_img <- read.csv(file.path(dir, "images_filtered.csv"), header = TRUE, sep = ";")
from <- tagged_img$file_path
to <- "E:/"
file.copy(from, to, recursive=TRUE, copy.date=TRUE)
The code runs and the list "from" contains every image i want to copy) but the copy I get has no folders or subfolders, and only 20000 photos out of 150000 are copied. I've noticed that the copied photos have unique names: e.g. there's only one IMG0001.jpg whereas in the .csv file with the list I have several photos named IMG0001.jpg
Any way to fix these and keep the folders and copy all the files? Thanks!
CodePudding user response:
tagged_img=list.files('E:/Imagenes/',all.files = T,full.names = T)
CodePudding user response:
I found out that I need to have the directory of the folders and subfolders in the same list; "from", that contains the directories of the images