check in lame scene_file fix and good beginning of fix_artist_album_date

This commit is contained in:
LuKe Tidd 2023-04-29 16:21:06 -04:00
parent b8789db0ef
commit e9de91b555
Signed by: luke
GPG Key ID: 75D6600BEF4E8E8F
2 changed files with 46 additions and 0 deletions

10
fix_artist_album_date Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
dir="$(pwd)"
readarray -t album_paths < <(find "$dir" -mindepth 1 -type d)
for path in "${album_paths[@]}"; do
year_album="$(sed 's#.*/##' <<< "$path")"
year="${year_album%% *}"
album="${year_album#* }"
printf 'Year: %s Album: %s\n' "$year" "$album"
done

36
fix_scene_file Executable file
View File

@ -0,0 +1,36 @@
#!/usr/bin/env python3
import os
import re
import sys
def is_flac(filename):
if len(filename) > 5 and filename[-5:].lower() == '.flac':
return True
return False
def fix_flac_name(filename):
return filename[:-5].replace('_', ' ').title() + '.flac'
def fix_name(filename):
fsplit = filename.split('.')
ext = fsplit[-1]
rest = ' '.join(fsplit[:-1])
rest = re.sub(' +', ' ', rest)
rest = rest.replace('_', ' ').title() + '.' + ext.lower()
return rest
files = os.listdir()
for file in files:
if is_flac(file):
new_file = fix_flac_name(file)
if new_file != file:
os.rename(file, new_file)
else:
new_file = fix_name(file)
if new_file != file:
os.rename(file, new_file)