danielecook
6/18/2014 - 9:50 PM

In conjunction with included bash, concatenates multiple files within folders (with foldername and filename)

In conjunction with included bash, concatenates multiple files within folders (with foldername and filename)

library(stringr)
library(dplyr)
"""
# Generate concatenated worm_track data using the following
for folder in `ls -d *\/`; do
    for file in `ls $folder/worm*`; do
        cat $file | awk -v file=$file '{print file","$1}' >> worm_track_all.txt
    done;
done;
"""

names(worm_track_all) <- c("Folder","time","x","y","blps","mmps")

worm_track_all[,c("Folder", "Filename")] <- str_split_fixed(worm_track_all$Folder, "///",2)