Hello !
I have a dataset of file names in which the date is nestled between other characters in a YYYYMMDD format. For example:
CBS20_WI-10005_V1_20200822_A_01, where 20200822 is the date.
There are some filenames, however, that have the date in a MMDDYYYY format. Is there any easy way to find the files that have the MMDDYYYY format and flip them to have a YYYYMMDD format? I have searched Google and am not finding an easy solution.
Here is a subset of my data:
structure(list(SITE_ID = c("NGL20_MI-10162", "NGL20_MI-10162",
"NGL20_MI-10163", "NGL20_MI-10163", "NGL20_MN-10001", "NGL20_MN-10001",
"NGL20_MN-10001", "NGL20_MN-10001", "NGL20_MN-10002", "NGL20_MN-10002",
"NGL20_MN-10002", "NGL20_MN-10002", "NGL20_MN-10002", "NGL20_MN-10002",
"NGL20_MN-10002", "NGL20_MN-10002", "NGL20_MN-10002", "NGL20_MN-10002",
"NGL20_MN-10002", "NGL20_MN-10002", "NGL20_MN-10003", "NGL20_MN-10003"
), DATE_COLLECTED = structure(c(18430, 18430, 18441, 18441, 18864,
18864, 18884, 18884, 18869, 18869, 18869, 18869, 18869, 18869,
18885, 18885, 18885, 18885, 18885, 18885, 18862, 18862), class = "Date"),
VISIT_NO = c(1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2,
2, 2, 2, 2, 2, 1, 1), CREW = c("GL1", "GL1", "GL1", "GL1",
"MN3", "MN3", "MN2", "MN2", "MN2", "MN2", "MN2", "MN2", "MN2",
"MN2", "MN2", "MN2", "MN2", "MN2", "MN2", "MN2", "MN3", "MN3"
), FILE_NAME = c("NGL20_MI-10162_V1_20200617_A_01", "NGL20_MI-10162_V1_20200617_B_01",
"NGL20_MI-10163_V1_20200628_A_01", "NGL20_MI-10163_V1_20200628_B_01",
"NGL20_MN-10001_V1_20200825_A_01", "NGL20_MN-10001_V1_20210825_B_01",
"NGL20_MN-10001_V2_20210914_A_01", "NGL20_MN-10001_V2_20210914_B_01",
"NGL20_MN-10002_V1_08302021_B_01", "NGL20_MN-10002_V1_08302021_B_02",
"NGL20_MN-10002_V1_08302021_B_03", "NGL20_MN-10002_V1_20210830_A_01",
"NGL20_MN-10002_V1_20210830_A_02", "NGL20_MN-10002_V1_20210830_A_03",
"NGL20_MN-10002_V2_09152021_A_01", "NGL20_MN-10002_V2_09152021_A_02",
"NGL20_MN-10002_V2_09152021_A_03", "NGL20_MN-10002_V2_09152021_B_01",
"NGL20_MN-10002_V2_09152021_B_02", "NGL20_MN-10002_V2_09152021_B_03",
"NGL20_MN-10003_V1_08232021_A_01", "NGL20_MN-10003_V1_08232021_B_01"
), START_TIME = c("0.0243055555555556", "0.0263888888888889",
"0.0208333333333333", "0.0201388888888889", "0.0381944444444444",
"0.0381944444444444", "0.0534722222222222", "0.0541666666666667",
"0.0131944444444444", "0.0173611111111111", "0.0381944444444444",
"0.0243055555555556", "0.0243055555555556", "0.0347222222222222",
"0.0118055555555556", "0.0131944444444444", "0.0180555555555556",
"0.0152777777777778", "0.0173611111111111", "0.0243055555555556",
"0.0902777777777778", "0.0645833333333333"), END_TIME = c("0.102777777777778",
"0.0979166666666667", "0.0743055555555556", "0.0729166666666667",
"0.122916666666667", "0.122916666666667", "0.125", "0.125",
"0.145833333333333", "0.122916666666667", "0.114583333333333",
"0.159722222222222", "0.131944444444444", "0.118055555555556",
"0.131944444444444", "0.158333333333333", "0.18125", "0.131944444444444",
"0.159027777777778", "0.177083333333333", "0.234027777777778",
"0.208333333333333"), VIDEO_QUALITY = c("GOOD", "GOOD", "GOOD",
"GOOD", "GOOD", "GOOD", "GOOD", "GOOD", "GOOD", "GOOD", "GOOD",
"GOOD", "GOOD", "GOOD", "GOOD", "GOOD", "GOOD", "GOOD", "GOOD",
"GOOD", "GOOD", "GOOD"), VEGETATION = c("N", "N", "N", "N",
"N", "N", "N", "N", "Y", "Y", "Y", "N", "Y", "N", "Y", "Y",
"N", "Y", "Y", "Y", "N", "N"), MUSSELS = c("N", "N", "N",
"N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N",
"N", "N", "N", "N", "N", "N", "N"), MUSSEL_ABUNDANCE = c("N",
"N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N",
"N", "N", "N", "N", "N", "N", "N", "N", "N"), DOM_SUBSTRATE = c("H",
"H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H",
"H", "H", "H", "H", "H", "H", "H", "S", "S"), HUMAN_FEATURES = c("N",
"N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N",
"N", "N", "N", "N", "N", "N", "N", "N", "N"), FISH = c("N",
"N", "N", "N", "Y", "Y", "Y", "Y", "N", "N", "N", "N", "N",
"N", "N", "N", "N", "N", "N", "N", "Y", "Y"), GOBIES = c("N",
"N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N",
"N", "N", "N", "N", "N", "N", "N", "N", "N"), OTHER_FISH = c("N",
"N", "N", "N", "Y", "Y", "Y", "Y", "N", "N", "N", "N", "N",
"N", "N", "N", "N", "N", "N", "N", "Y", "Y"), NOTES = c(NA,
NA, NA, NA, NA, NA, NA, NA, "WATER MUST HAVE ENTERED CAMERA CASE, GETS BLURRY",
"WATER MUST HAVE ENTERED CAMERA CASE, GETS BLURRY", NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, "1 FISH", "SILVERY LONG FISH, ONLY WATCHED UNTIL 3:30 AS VIDEO FAR EXCEEDS 1 MIN ON SEDIMENT"
), COCR_COMMENTS = c("Correct", "Correct", "Correct", "Correct",
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA)), row.names = 586:607, class = "data.frame")
Thanks so much!