-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import os | ||
import shutil | ||
from tqdm import tqdm | ||
|
||
class Pull_From_Abyss: | ||
dst_dir = os.getcwd() + '/files from abyss/' | ||
abyssal_files_count = 0 | ||
abyssal_dir = '' | ||
ext = '' | ||
|
||
def __init__(self, abyssal_dir, extension = 'all'): | ||
self.abyssal_dir = abyssal_dir | ||
self.ext = extension | ||
|
||
self.verify_output_dir() | ||
|
||
files_path = self.abyssal_files_path(abyssal_dir, extension) | ||
self.pull_from_abyss(files_path) | ||
|
||
def verify_output_dir(self): | ||
output_folder = os.getcwd() + '/files from abyss/' | ||
|
||
if not os.path.exists(output_folder): | ||
os.mkdir(output_folder) | ||
|
||
def abyssal_files_path(self, abyssal_dir, ext): | ||
abyssal_walker = os.walk(abyssal_dir) | ||
files_in_abyss = [] | ||
|
||
for dirpath, dirnames, filenames in abyssal_walker: | ||
for filename in filenames: | ||
if ext != 'all' and not filename.endswith(ext): | ||
print(filename) | ||
continue | ||
|
||
file_path = f'{dirpath}/{filename}' | ||
files_in_abyss.append(file_path) | ||
|
||
self.abyssal_files_count = len(files_in_abyss) | ||
print(f"Found {self.abyssal_files_count} files\n") | ||
|
||
return files_in_abyss | ||
|
||
def pull_from_abyss(self, files_path): | ||
for path in tqdm(files_path, desc="Pulling files from the abyss"): | ||
filename = path.rsplit('/', 1)[1] | ||
final_dst = self.dst_dir + filename | ||
shutil.move(path, final_dst) | ||
|
||
print(f"Successfully moved {self.abyssal_files_count} files to {self.dst_dir}") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from abyss import Pull_From_Abyss | ||
from tkinter import Tk, filedialog | ||
|
||
Tk().withdraw() | ||
abyssal_dir = filedialog.askdirectory(title='Select Source Folder') | ||
|
||
Pull_From_Abyss(abyssal_dir) | ||
|
||
input("\nPress Enter to exit") | ||
exit() |