-
Notifications
You must be signed in to change notification settings - Fork 2
/
SALAMI_parser.py
28 lines (22 loc) · 903 Bytes
/
SALAMI_parser.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
import os
folder_path = "./datasets/SALAMI/audio"
"""
# Iterate through all files in the folder
for filename in os.listdir(folder_path):
# Check if the file is an mp3 file
if filename.endswith(".mp3"):
# Create a new filename with the "SALAMI_" prefix
new_filename = "SALAMI_" + filename
# Get the full path of the original and new file
original_file_path = os.path.join(folder_path, filename)
new_file_path = os.path.join(folder_path, new_filename)
# Rename the file
os.rename(original_file_path, new_file_path)
print("All mp3 files have been renamed.")
"""
for filename in os.listdir(folder_path):
if filename.startswith("SALAMI_SALAMI_"):
new_filename = filename.replace("SALAMI_SALAMI_", "SALAMI_")
os.rename(
os.path.join(folder_path, filename), os.path.join(folder_path, new_filename)
)