Last active
October 11, 2016 09:50
-
-
Save thekoc/3111a48114c8a115cfd70c8eb6fd4c36 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
echo 'import os | |
import sys | |
import shutil | |
def main(): | |
root_path = sys.argv[1] | |
assert os.path.isdir(root_path) | |
assert len(os.listdir(root_path)) == 1000 | |
for path in filter(lambda p: p != ".DS_Store", os.listdir(root_path)): | |
abs_base_path = os.path.join(root_path, path) | |
if len(os.listdir(abs_base_path)) > 0: | |
if len(os.listdir(abs_base_path)) == 1: | |
abs_child_path = os.path.join(abs_base_path, os.listdir(abs_base_path)[0]) | |
assert os.path.isdir(abs_child_path) | |
[shutil.move(os.path.join(abs_child_path, src), abs_base_path) for src in os.listdir(abs_child_path)] | |
os.removedirs(abs_child_path) | |
else: | |
assert all(os.path.isfile(p) for p in os.listdir(abs_base_path)) | |
print("All done.") | |
if __name__ == "__main__": | |
main()' > temunique92.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment