Skip to content

Instantly share code, notes, and snippets.

@mrdwab
Created May 8, 2020 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrdwab/633979f2d0d61b9619fa645d8cff121b to your computer and use it in GitHub Desktop.
Save mrdwab/633979f2d0d61b9619fa645d8cff121b to your computer and use it in GitHub Desktop.
x <- readLines("~/Downloads/Andy - Career Talk/exported.srt")
cat(x[1:10], sep = "\n")
## 1
## 00:00:00,640 --> 00:00:12,850
## [Music]
##
## 2
## 00:00:12,850 --> 00:00:19,910
## Hi, my name is Andy Liepman, and Partners
##
## 3
## 00:00:19,910 --> 00:00:23,900
## NULL
## Which lines need to be fixed
y <- x[seq(from = 6, to = length(x), by = 4)]
## Increment the first number after the comma by 1
substring(y, 10, 12) <- sprintf("%03d", as.numeric(substr(y, 10, 12))+1)
## Replace the old timecode with the new one
x[seq(from = 6, to = length(x), by = 4)] <- z
## But what about "00:00:19,999" ?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment