Matroxt / one-pace-to-plex

Guide to adapt One Pace releases to a format Plex can use
78 stars 8 forks source link

Search sub-directory folder structure #16

Closed Overlord360 closed 1 year ago

Overlord360 commented 1 year ago

Add -sd or --sub-dir argument to allow the script to search through the one pace folder structure (e.g. "Arc 01 - Romance Dawn/file.mkv")

Changed some variables to be file paths instead of file names to facilitate the change

Updated README with instructions on how to use it.

Matroxt commented 1 year ago

I like the idea!

However, can we rename --sub-dir to --recurse "Recurse" seems like the proper term for what we're trying to do and it's a standard programing word.

Overlord360 commented 1 year ago

We can, but it doesn't really recurse as it only searches one directory level deep as that's the intended file structure e.g. "./One Piece [tvdb4-81797]/Arc 01 - Romance Dawn/file.mkv"

Overlord360 commented 1 year ago

I've changed the argument, It's a fairly easy change to make it truly recursive if we want to search through nested sub-directories as well

Matroxt commented 1 year ago

Yeah, I think we should travers the directories

import os
...
for root, dirs, files in os.walk(directory):
    for file in files:
        if file.endswith(".mkv"):
             print(os.path.join(root, file))
Overlord360 commented 1 year ago

The script will now recursively search all sub directories and any nested directories

Matroxt commented 1 year ago

It looks good, but I want to test it first. I don't have access to my computer currently, I'll let you know when it's tested and I'll approve.