Skip to content

Commit

Permalink
feat: add scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
oscaromeu committed Jan 26, 2025
1 parent 0b14ba9 commit 54f2394
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 0 deletions.
73 changes: 73 additions & 0 deletions scripts/config/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
renaming_scheme:
- old_name_pattern: "mixtape_320_000"
new_name: ""
#- old_name_pattern: "mixtape_320_001"
# new_name: ""
#- old_name_pattern: "mixtape_320_002"
# new_name: ""
#- old_name_pattern: "mixtape_320_003"
# new_name: ""
#- old_name_pattern: "mixtape_320_004"
# new_name: ""
#- old_name_pattern: "mixtape_320_005"
# new_name: ""
#- old_name_pattern: "mixtape_320_006"
# new_name: ""
#- old_name_pattern: "mixtape_320_007"
# new_name: ""
#- old_name_pattern: "mixtape_320_008"
# new_name: ""
#- old_name_pattern: "mixtape_320_009"
# new_name: ""
#- old_name_pattern: "mixtape_320_0010"
# new_name: ""
#- old_name_pattern: "mixtape_320_0011"
# new_name: ""
#- old_name_pattern: "mixtape_320_0012"
# new_name: ""
#- old_name_pattern: "mixtape_320_0013"
# new_name: ""
#- old_name_pattern: "mixtape_320_0014"
# new_name: ""
#- old_name_pattern: "mixtape_320_0015"
# new_name: ""
#- old_name_pattern: "mixtape_320_0016"
# new_name: ""
#- old_name_pattern: "mixtape_320_0017"
# new_name: ""
#- old_name_pattern: "mixtape_320_0018"
# new_name: ""
#- old_name_pattern: "mixtape_320_0019"
# new_name: ""
#- old_name_pattern: "mixtape_320_0020"
# new_name: ""
#- old_name_pattern: "mixtape_320_0021"
# new_name: ""
#- old_name_pattern: "mixtape_320_0022"
# new_name: ""
#- old_name_pattern: "mixtape_320_0023"
# new_name: ""
#- old_name_pattern: "mixtape_320_0024"
# new_name: ""
#- old_name_pattern: "mixtape_320_0025"
# new_name: ""
#- old_name_pattern: "mixtape_320_0026"
# new_name: ""
#- old_name_pattern: "mixtape_320_0027"
# new_name: ""
#- old_name_pattern: "mixtape_320_0028"
# new_name: ""
#- old_name_pattern: "mixtape_320_0029"
# new_name: ""
#- old_name_pattern: "mixtape_320_0030"
# new_name: ""
#- old_name_pattern: "mixtape_320_0031"
# new_name: ""
#- old_name_pattern: "mixtape_320_0032"
# new_name: ""
#- old_name_pattern: "mixtape_320_0033"
# new_name: ""
#- old_name_pattern: "mixtape_320_0034"
# new_name: ""
#- old_name_pattern: "mixtape_320_0035"
# new_name: ""
36 changes: 36 additions & 0 deletions scripts/mp3_vinyl_renamer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import os
import yaml

def load_config(config_path):
"""Load the renaming configuration from a YAML file."""
with open(config_path, 'r') as file:
return yaml.safe_load(file)

def get_files_in_directory(directory_path):
"""Get a sorted list of filenames in the directory."""
return sorted(os.listdir(directory_path))

def rename_files(directory_path, config):
"""Rename files in the directory based on the provided configuration."""
files = get_files_in_directory(directory_path)

for i, file_name in enumerate(files):
for rename_rule in config['renaming_scheme']:
# Match the old_name_pattern and rename the file
if rename_rule['old_name_pattern'] in file_name:
old_file_path = os.path.join(directory_path, file_name)
new_file_name = rename_rule['new_name']
new_file_path = os.path.join(directory_path, new_file_name)
os.rename(old_file_path, new_file_path)
print(f"Renamed: {file_name} -> {new_file_name}")
break # Once matched and renamed, no need to check further rules

if __name__ == "__main__":
directory = "/Volumes/MUSIC/Reloop Tape" # Change this to your target directory
config_file = "config.yaml" # Path to the config file

# Load the config file
config = load_config(config_file)

# Rename files based on the configuration
rename_files(directory, config)

0 comments on commit 54f2394

Please sign in to comment.