Move scripts dir inside hm
And remove weird path contraptions
This commit is contained in:
parent
050901da2f
commit
edeef96133
49 changed files with 2 additions and 11 deletions
34
hm/scripts/music_remove_dashes
Executable file
34
hm/scripts/music_remove_dashes
Executable file
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 --pure
|
||||
#! nix-shell -p python3
|
||||
|
||||
"""
|
||||
Small script to convert music files in the form:
|
||||
$(tracknumber) - $(title).$(ext)
|
||||
to the form
|
||||
$(tracknumber) $(title).$(ext)
|
||||
(note the absence of dash)
|
||||
"""
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
|
||||
def main() -> None:
|
||||
"""
|
||||
Function that executes the script.
|
||||
"""
|
||||
for root, _, files in os.walk("."):
|
||||
for filename in files:
|
||||
match = re.match(r"^(\d+) - (.+)$", filename)
|
||||
if not match:
|
||||
continue
|
||||
new_filename = f"{match[1]} {match[2]}"
|
||||
old_path = os.path.join(root, filename)
|
||||
new_path = os.path.join(root, new_filename)
|
||||
print(old_path, "->", new_path)
|
||||
os.rename(old_path, new_path)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Add table
Add a link
Reference in a new issue