Watch 2 Star 2 Fork 0

RCPI / pi4bPythonMulanPSL-2.0

Join us
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
这里是针对树莓派4B的远程控制类python程序代码 spread retract

https://gitee.com/rcpi/pi4b

Clone or download
changename.py 1.37 KB
Copy Edit Web IDE Raw Blame History
RCPI authored 2020-03-28 03:23 . windows批量改后缀
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
本代码仅限应用于Microsoft Windows系列系统
'''
import os
import time
doscls = os.system("cls")
listpath = input('请输入目标文件夹(请以\"\\"结尾):')
files = os.listdir(listpath)
old_por = input('请输入欲修改后缀(不含\".\"):')
new_por = input('请输入欲改成后缀(不含\".\"):')
for old_name in files:
portion = os.path.splitext(old_name)
#print(listpath + old_name,'的后缀是:',portion[1])
if portion[1] == "." + old_por:
new_name = listpath + portion[0] + "." + new_por
file_name = listpath + old_name
os.rename(file_name, new_name)
print("文件 ", file_name, " 的格式已更改为 ", portion[0] + "." + new_por)
time.sleep(0.1)
# doscls=os.system("cls")
'''
def printer(text,delay=0.1):
"""打字机效果"""
for ch in text:
print(ch,end = ' ', flush=True)
time.sleep(delay)
printer("请稍等,其实文件名称早就改完了,我只不过在这里跑一下效果\n你现在就可以关掉这个窗口了,下面的效果真心没有什么大用,我就是想秀一下")
print('')
files=os.listdir(listpath)
for old_name in files:
portion=os.path.splitext(old_name)
if portion[1] == "." + new_por:
file_name=listpath + old_name
print("文件 " +file_name + " 已更改完成")
time.sleep(0.1)
'''

Comment ( 0 )

Sign in for post a comment

Python
1
https://gitee.com/rcpi/pi4b.git
git@gitee.com:rcpi/pi4b.git
rcpi
pi4b
pi4b
master

Help Search

205735 778617b6 1899542 205747 347fc4a1 1899542