Skip to content

Commit

Permalink
Lets try this on for size
Browse files Browse the repository at this point in the history
  • Loading branch information
lunamidori5 committed Nov 17, 2024
1 parent 70d70ee commit 7cdc598
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Webserver/Programs/File_manager/file_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,20 @@ def compress_tar():
def flatten_directory():
""" Flatten a directory by moving all files to the starting directory and removing the nested folders.
"""

for root, dirs, files in os.walk(temp_workfolder):
print('Root: {}, Dirs: {}, Files: {}'.format(root, dirs, files))
for file in files:
file_path = os.path.join(root, file)
new_file_path = os.path.join(temp_workfolder, file)
print('Moving {} to {}'.format(file_path, new_file_path))
os.rename(file_path, new_file_path)

for root, dirs, files in os.walk(temp_workfolder):
print('Root: {}, Dirs: {}, Files: {}'.format(root, dirs, files))
for dir in dirs:
dir_path = os.path.join(root, dir)
if not os.listdir(dir_path):
print('Removing empty directory: {}'.format(dir_path))
os.rmdir(dir_path)

def uncompress_tar(dst_dir):
Expand Down

0 comments on commit 7cdc598

Please sign in to comment.