-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmerge.py
45 lines (32 loc) · 1.23 KB
/
merge.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
import os
import click
from filesplit.merge import Merge
def delete_file_extension(filename):
"""Deletes the file extension of a file.
Args:
filename: The path to the file.
"""
basename = os.path.basename(filename)
ext = os.path.splitext(basename)[1]
new_filename = basename.replace(ext, "")
os.rename(filename, os.path.join(os.path.dirname(filename), new_filename))
def delete_file_extensions_in_folder(folder_path):
"""Deletes the file extension of all files in a folder.
Args:
folder_path: The path to the folder.
"""
for file in os.listdir(folder_path):
file_path = os.path.join(folder_path, file)
if os.path.isfile(file_path):
delete_file_extension(file_path)
@click.command()
@click.option("--folder", default="./", help="Input folder path")
@click.option("--output-folder", default="BACKUP_OUTPUT_FOLDER", help="Output folder path")
def main(folder, output_folder):
delete_file_extensions_in_folder(folder)
if not os.path.exists(output_folder):
os.makedirs(output_folder)
merge = Merge(inputdir=folder, outputdir=output_folder, outputfilename="full_github_backup.tar.zstd")
merge.merge()
if __name__ == "__main__":
main()