Created
June 30, 2018 18:04
-
-
Save chrisjrn/0ab3e1169110b454a5876903e30b5ebd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| wget -r --mirror --page-requisites SOURCE_DOMAIN -D SOURCE_DOMAIN --adjust-extension | |
| ''' | |
| import os | |
| import sys | |
| basedir = sys.argv[1] | |
| directories = [] | |
| moves = [] | |
| for folder, subdirs, files in os.walk(basedir): | |
| for f in files: | |
| basename, dot, ext = f.rpartition(".") | |
| if not basename: | |
| continue | |
| if ext != "html": | |
| continue | |
| if basename == "index": | |
| continue | |
| if basename not in subdirs: | |
| directories.append((folder, basename)) | |
| moves.append((folder, basename, f)) | |
| for folder, basename in directories: | |
| a = os.path.join(folder, basename) | |
| print("mkdir", folder, basename) | |
| os.mkdir(a) | |
| for folder, dest, filename in moves: | |
| orig = os.path.join(folder, filename) | |
| nd = os.path.join(folder, dest, "index.html") | |
| print("mv : " + orig + " -to- " + nd) | |
| os.rename(orig, nd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment