Python script to search for file names
by secretleakbuyer - Tuesday June 13, 2023 at 10:57 AM
#1
=========================================================================================
Part-1

import os

for i in os.walk("PATH_TO_DIR"):
    for fn in i[2]:
        if any(m in fn for m in ["DVD", "RIP", "R5"]) and (".avi" in fn or ".mkv" in fn):
            print(os.path.join(i[0], fn))


Using pathlib.

from pathlib import Path

# find files
files = Path.cwd().glob('filename.*')

# find files with REGex
files = Path.cwd().rglob('**/mnt/folder/Movies/*RIP*|*R5*')

==============================================================================
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python pathlib: suffix, suffixes and stem for compound filenames nolookshot 0 191 10-16-2026, 02:41 PM
Last Post: nolookshot
  Python timezone-aware timestamps versus elapsed durations nolookshot 0 104 10-16-2026, 02:40 PM
Last Post: nolookshot
  Python CSV: handling quoted commas and embedded newlines nolookshot 0 112 10-16-2026, 02:39 PM
Last Post: nolookshot
  Retrieving Firefox Cookies Using Python Aurora 15 6,035 09-10-2026, 03:29 AM
Last Post: realtruth
  [Tutorial] Bruteforce Any RDP Using Python 0x666 56 6,543 02-08-2026, 02:17 PM
Last Post: lombardi



 Users browsing this thread: 1 Guest(s)