Let my HOME alone 1/2
This commit is contained in:
parent
2ae37e902e
commit
a83e45df5e
94 changed files with 328 additions and 58 deletions
39
config/scripts/musiqueBof
Executable file
39
config/scripts/musiqueBof
Executable file
|
@ -0,0 +1,39 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import os
|
||||
import shutil
|
||||
import logging
|
||||
import coloredlogs
|
||||
|
||||
coloredlogs.install(level='DEBUG', fmt='%(levelname)s %(message)s')
|
||||
log = logging.getLogger()
|
||||
|
||||
MUSICS_FOLDER = os.path.join(os.path.expanduser("~"), "Musique")
|
||||
BOF_FOLDER = os.path.join(os.path.expanduser("~"), ".MusiqueBof")
|
||||
|
||||
for f in sys.argv[1:]:
|
||||
src = os.path.realpath(f)
|
||||
if not os.path.isfile(src):
|
||||
log.error("{} does not exists".format(src))
|
||||
continue
|
||||
|
||||
srcBase = None
|
||||
if src.startswith(MUSICS_FOLDER):
|
||||
srcBase = MUSICS_FOLDER
|
||||
dstBase = BOF_FOLDER
|
||||
elif src.startswith(BOF_FOLDER):
|
||||
srcBase = BOF_FOLDER
|
||||
dstBase = MUSIC_FOLDER
|
||||
else:
|
||||
log.error("{} not in any music folder".format(src))
|
||||
continue
|
||||
|
||||
common = os.path.relpath(src, srcBase)
|
||||
dst = os.path.join(dstBase, common)
|
||||
dstFolder = os.path.dirname(dst)
|
||||
|
||||
log.info("{} → {}".format(src, dst))
|
||||
os.makedirs(dstFolder, exist_ok=True)
|
||||
shutil.move(src, dst)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue