Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- from os import listdir, rename, remove, mkdir, path
- from os.path import join, isdir
- BASE_PATH = path.abspath(path.dirname(__file__))
- SOURCE_PATH = BASE_PATH + "/new"
- CURRENT_PATH = BASE_PATH + "/sorted"
- # NAME_RE = r"(^\[.+?\])\s*?(.+$)"
- NAME_RE = r"(^\[.+?\])\s*?(.+)\s*?(\(.+?\))\s*?(\{.+?})(.+$)"
- if "sorted" not in listdir(BASE_PATH):
- mkdir(join(BASE_PATH, "sorted"))
- current_artists = [f for f in listdir(CURRENT_PATH) if isdir(join(CURRENT_PATH, f))]
- mangas = dict((f, join(SOURCE_PATH, f)) for f in listdir(SOURCE_PATH) if isdir(join(SOURCE_PATH, f)))
- artists_name = set([re.match(NAME_RE, name).group(1).strip("[] ") for name in list(mangas.keys())])
- print(mangas.keys())
- for artist_name in artists_name:
- if artist_name not in current_artists:
- mkdir(join(CURRENT_PATH, artist_name))
- for name, manga_path in mangas.items():
- artist_name = re.match(NAME_RE, name).group(1).strip("[] ")
- artist = re.match(NAME_RE, name).group(1)
- manga_name = re.match(NAME_RE, name).group(2).strip()
- comic_name = re.match(NAME_RE, name).group(3)
- tags_ = re.match(NAME_RE, name).group(4)
- ext_type = re.match(NAME_RE, name).group(5)
- artist_path = join(CURRENT_PATH, artist_name)
- current_mangas = [f for f in listdir(artist_path) if isdir(join(artist_path, f))]
- if manga_name in current_mangas:
- continue
- print(manga_name)
- # rename(manga_path, join(artist_path, manga_name))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement