描述:在win10中用BliBli批量下载视频,每个生成的视频文件单独放在一个文件夹中,用播放器一个一个点播放不方便
代码:
import os;
import shutil;
def scandir(dir):
with os.scandir(dir) as it:
for entry in it:
if not entry.is_file():
scandir(entry)
else :
if entry.name.endswith(".flv"):
shutil.move(entry,"G:\孽畜-碗里来\15369076\flv\"+entry.name)
def returnjava(name):
if "flv" in name:
return returnjava(name.replace("flv",""))
else :
return name
def scandir1(dir):
with os.scandir(dir) as it:
for entry in it:
if entry.is_file() and entry.name.endswith(".flv"):
name =entry.name.split(".")
copyname1 = returnjava(name[0])
//切换目录到指定文件夹,默认桌面
os.chdir(dir)
os.rename(entry.name,copyname1+"."+name[1])
if __name__=="__main__":
## 解决scandir函数中move操作的源文件目录末尾没有加\导致的文件名错误。
scandir1("G:\孽畜-碗里来\78543450")
## 处理blibli视频下载后文件被单独放在一个文件夹打开不方便的问题
scandir("G:\孽畜-碗里来\78543450")