Mercurial > hg > pub > prymula > scripts
view bandm3u/bandm3u.py @ 35:7cf972a1889d
bing4desktop-0.240209-0_version fix
author | prymula <prymula76@outlook.com> |
---|---|
date | Fri, 09 Feb 2024 18:39:07 +0100 |
parents | dcd610585610 |
children |
line wrap: on
line source
#!/usr/bin/env python3 # bandm3u- skrypt do tworzenia playlist m3u # 16-02-2023 # Edytor: Geany # (c) by P.R.P # Mój pierwszy skrypt stworzony w Windows 11 import os dir = os.getcwd() data_files = [] data_out = [] extension = ['mp3', 'ogg', 'wav'] def check(string, sub_str): if (string.find(sub_str) == -1): return False else: return True for data in os.listdir(dir): for e in extension: if check(data, e): data_files += [os.path.basename(data)] #print (data_files) for n in range(100): for f in data_files: if n > 9: nn = str(n)+" " else: nn = "0"+str(n)+" " # sprawdza liczbę porządkową if check(f, nn): data_out.insert(n, f) c = '\\' # indeksy wysępowania znaku slash/unslash w łańcuchu slash = [pos for pos, char in enumerate(dir) if char == c] # zdejmuje ostatni indeks last_slash = slash.pop() f=open(dir[last_slash+1:]+".m3u","w+") # file name and mode for x in range(0, len(data_out)): f.writelines(data_out[x]) f.writelines("\r\n") f.close() print (dir) print (data_out)