-
Notifications
You must be signed in to change notification settings - Fork 0
/
file_utilities.py
60 lines (39 loc) · 1.36 KB
/
file_utilities.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import os
import tkinter as tk
from tkinter import filedialog
def get_file_list(the_folder):
"""
> It takes a folder name as input, and returns a dictionary with two keys: "files" and "count". The
"files" key contains a list of the files in the folder, and the "count" key contains the number of
files in the folder
Args:
the_folder: The folder to get the file list from.
Returns:
A dictionary with two keys: files and count.
"""
the_files = os.listdir(os.path.abspath(the_folder))
return {"files": the_files, "count": len(the_files)}
def get_root_dir():
"""
It opens a file dialog box and returns the path of the directory selected by the user
Returns:
The root directory path
"""
root_path = filedialog.askdirectory(title="Select the Directory")
return root_path
def get_file_path():
"""
It opens a file dialog box and returns the path of the file selected by the user
Returns:
The file path of the file that the user selected.
"""
file_path = filedialog.askopenfilename(title="Select the File")
return file_path
def get_file_paths():
"""
It opens a file dialog box and allows the user to select multiple files
Returns:
A tuple of file paths
"""
file_paths = filedialog.askopenfilenames(title="Select the Files")
return file_paths