Here's my problem:
I collected data and it is in 145 folders
each representing a separate measurement (inside each folder are 100 csv files)
19 of these folders are "Si" measurements, which I want to move into a new folder called "Si" to exclude in later work
I made a list of those folders and tried to move them with
file.copy
I get all FALSE.
Ideas?
side note: I want them MOVED, not COPIED. but I simplified it for now
here's my code, followed by some outputs:
path = "C:/Users/anakar/Desktop/HOME OFFICE/Klebsiella/Data for analysis/SpRaw - dummy" # Where the data is stored
current.folder <- path
all.folders = list.files(current.folder, full.names = TRUE) # Makes a list of all the folders
all.folders.Si = all.folders[grepl("~si",all.folders, ignore.case = T)] # Checks which lines have "~Si" in them and gives them a "TRUE" value in the standard column
new.Si.folder <- paste(current.folder,"/Si", sep = "") # Where I want my files to be copied to
dir.create(new.Si.folder) # Creates that target folder
file.copy(all.folders.Si, to = new.Si.folder) # SHOULD copy the folders to the new directory
Outputs:
> head(all.folders)
[1] "C:/Users/anakar/Desktop/HOME OFFICE/Klebsiella/Data for analysis/SpRaw - dummy/AN~20201027~K.P~4aap"
[2] "C:/Users/anakar/Desktop/HOME OFFICE/Klebsiella/Data for analysis/SpRaw - dummy/AN~20201027~K.P~E.~coli~Gr05"
[3] "C:/Users/anakar/Desktop/HOME OFFICE/Klebsiella/Data for analysis/SpRaw - dummy/AN~20201027~K.P~E.coli~Gr06"
[4] "C:/Users/anakar/Desktop/HOME OFFICE/Klebsiella/Data for analysis/SpRaw - dummy/AN~20201027~K.P~K.~pne~A91"
[5] "C:/Users/anakar/Desktop/HOME OFFICE/Klebsiella/Data for analysis/SpRaw - dummy/AN~20201027~K.P~K.~pne~Gr18"
[6] "C:/Users/anakar/Desktop/HOME OFFICE/Klebsiella/Data for analysis/SpRaw - dummy/AN~20201027~K.P~K.pne~A99"
> head(all.folders.Si)
[1] "C:/Users/anakar/Desktop/HOME OFFICE/Klebsiella/Data for analysis/SpRaw - dummy/AN~20201027~K.P~Si"
[2] "C:/Users/anakar/Desktop/HOME OFFICE/Klebsiella/Data for analysis/SpRaw - dummy/AN~20201028~K.P~Si"
[3] "C:/Users/anakar/Desktop/HOME OFFICE/Klebsiella/Data for analysis/SpRaw - dummy/AN~20201029~K.P~Si"
[4] "C:/Users/anakar/Desktop/HOME OFFICE/Klebsiella/Data for analysis/SpRaw - dummy/AN~20201030~K.P~Si"
[5] "C:/Users/anakar/Desktop/HOME OFFICE/Klebsiella/Data for analysis/SpRaw - dummy/AN~20201103~K.P~Si"
[6] "C:/Users/anakar/Desktop/HOME OFFICE/Klebsiella/Data for analysis/SpRaw - dummy/AN~20201104~K.P~Si"
> file.copy(all.folders.Si, to = new.Si.folder)
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE