forked from bp-sensr/ndpc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRename_post_zoomz_location+dates.R
More file actions
60 lines (43 loc) · 1.84 KB
/
Copy pathRename_post_zoomz_location+dates.R
File metadata and controls
60 lines (43 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Rename zoom files by adding Square/Point locations to file names from csv file
library(stringr)
library(tidyverse)
#Set Observer/processing variable
obs_date_var <- "Kirkland-20240108"
############################################
#Below this shouldn't require any changes
############################################
#Set working directory
wd <- str_c("C:/Users/Kevin Kelly/Desktop/", obs_date_var, "/Uploaded")
setwd(wd)
#Create csv code
csv_locations_name <- str_c(obs_date_var, ".csv", sep = "")
csv_locations_dropped_name <- str_c(obs_date_var, "_dropped", ".csv", sep = "")
zoomz_locations <- read.csv(csv_locations_name)
view(zoomz_locations)
#############
#Remove unnecessary lines from csv
#############
#Drop files too short
zoomz_locations_drop <- zoomz_locations[zoomz_locations$new_path != "File too short for task length",]
#Check that number of lines in csv with location data matches number of files in folder
nrow(zoomz_locations_drop)
length(list.files(pattern = ".wav"))
identical(nrow(zoomz_locations_drop), length(list.files(pattern = ".wav")))
write.csv(zoomz_locations_drop, file=csv_locations_dropped_name)
#Get current file names - ensure only 1 copy of each exists
current_file_names <- list.files(pattern = ".wav")
current_file_names
#Remove Matchedbyuser location string
current_file_minus <- str_replace(current_file_names, "Matchedbyuser_", "_")
current_file_minus
#Read in csv with Location information - ensure lines with no subsequent file were removed
locations_dropped <- read.csv(csv_locations_dropped_name)
View(locations_dropped)
#Identify location string
location <- locations_dropped$location
location
#Combine new location string with date+time filename
new_file_names <- str_c(location, "", current_file_minus)
new_file_names
#Rename files with location string and date+time
file.rename(current_file_names, new_file_names)