-
Notifications
You must be signed in to change notification settings - Fork 0
/
CleanUp.py
28 lines (20 loc) · 1.16 KB
/
CleanUp.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
#-------------------------------------------------------------------#
# BatchWhisper-Transcription-Translation [LOCAL & API] #
#-------------------------------------------------------------------#
# Author: SABIAN HIBBS #
# License: MIT #
# Version: 3.4 #
#-------------------------------------------------------------------#
import os
# Define the path to the 'Videos' folder
videos_folder = "./Videos"
# Loop through each subdirectory in the 'Videos' folder
for subdir in os.listdir(videos_folder):
subdir_path = os.path.join(videos_folder, subdir)
# Get a list of all files in the subdirectory
files = os.listdir(subdir_path)
# Get the file with the largest size
largest_file = max(files, key=lambda f: os.path.getsize(os.path.join(subdir_path, f)))
# Rename the subdirectory to the name of the largest file
new_name = os.path.splitext(largest_file)[0] # Remove the file extension
os.rename(subdir_path, os.path.join(videos_folder, new_name))