Assuming you are working only with files inside "Form S-1" folder, this should work
library(stringr)
text <- c("/run/media/bb/cc/GA/DrRao/JOBS/Edgar filings_full text/Form S-1/1001171/1001171_S-1_2013-11-20_0001104659-13-086087.txt",
"/run/media/bb/cc/GA/DrRao/JOBS/Edgar filings_full text/Form S-1/1001172/1001172_S-1_2013-01-20_0001104659-13-086087.txt")
str_extract(text, "(?<=S-1/)\\d{7}")
#> [1] "1001171" "1001172"
You can extract any substring as long as it follows a pattern and you can describe it with a regular expression.