Last active
June 14, 2019 13:14
-
-
Save kerolloz/f88a48c03fb66cdcf2681c22732c90e6 to your computer and use it in GitHub Desktop.
This file contains 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
""" | |
This script extracts nested files from their folders to the outter folder | |
say in the current dir we have the following folders: | |
f1 | |
f2 | |
f3 | |
each one has folders inside of it and those folders have files inside of them | |
this script will get those files from the nested folders to the outer level | |
""" | |
import os | |
def main(): | |
play_lists = os.listdir(os.curdir) | |
for playlist in play_lists: | |
if os.path.isdir(playlist): | |
os.chdir(playlist) | |
lessons = os.listdir(os.curdir) | |
for lesson in lessons: | |
if os.path.isdir(lesson): | |
os.chdir(lesson) | |
videos = os.listdir(os.curdir) | |
for video in videos: | |
from_ = video | |
to_ = '../' + video | |
print(from_, to_) | |
os.rename(from_, to_) | |
os.chdir('..') | |
os.chdir('..') | |
if __name__ == '__main__': | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment