My input files are html files with no extension. Desired output is regex matched URLs from all files from the root_dir and results joined in single file. My regex works and I can output results from a single file.
import re
with open('/Users/files/filename') as f:
for line in f:
urls = re.findall (r"([\w%~\+-=]*\.mp3)", line);
print (*urls)
I could use glob but unsure how to:
import glob
import re
root_dir = '/Users/files/'
for filename in glob.iglob(root_dir + '**/*.*', recursive=True):
urls = re.findall (r"([\w%~\+-=]*\.mp3)", line);
print (*urls)
open('/Users/files/')?? Your second code sample misses anopen(filename)statement.