-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmedia-manager-sh.py
executable file
·41 lines (34 loc) · 1.23 KB
/
media-manager-sh.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
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/python3.7
import sys
import sh
path = sys.argv[1]
if len(sys.argv) != 2:
print("Please provide one path as parameter (more than one parameter)")
sys.exit()
try:
sh.test("-d", path)
except sh.ErrorReturnCode_1:
print("Please provide one path as parameter (parameter is not a path)")
sys.exit()
print("Welcome to the show, rename, delete media manager")
feh_extensions = ["jpeg", "png", "jpg", "pnm", "tiff", "bmp", "mov"]
mpv_extensions = ["m4a", "3gp", "3g2", "mj2", "gif", "mp4"]
for file in str(sh.find(path, "-maxdepth", "1", "-type", "f")).split("\n"):
extension = file.split(".")[-1]
if extension not in feh_extensions and extension not in mpv_extensions:
continue
elif extension in feh_extensions:
sh.feh("--full-screen", file)
elif extension in mpv_extensions:
sh.mpv("--fullscreen", file)
print(path)
operator = input("do you want to do n(othing), d(elete), r(ename): ")
if operator == "d":
sh.rm(file)
elif operator == "r":
new_name = input(" new name:")
sh.mv(file, path+new_name+"."+file.split(".")[-1])
elif operator == "q":
break
else:
print("do nothing")