当前位置:网站首页>Rename all files in the folder with one click
Rename all files in the folder with one click
2022-06-21 11:42:00 【Energetic wangdapeng】
background
During the cloud disk course , I found that many course suffixes will add some special signs , Feeling affects the structured look and feel , At the same time, if the data has a code , This kind of identification will also affect the code to open directly . So I made a simple one key traversal program , And package it as exe.
Ideas
- Given the file path of a parent directory , And the contents of the file name to be deleted ;
- Scan down to the root file name , Then the root file name is rename;
Code
import os
import sys
def get_files(filename):
for filepath,dirnames,filenames in os.walk(filename):
for filename in filenames:
target_name = os.path.join(filepath,filename)
# print(target_name)
os.rename(target_name, target_name.replace(' Contents to be removed ',''))
print(' Processing is complete ')
def convert_path(path):
return path.replace(r'\/'.replace(os.sep, ''), os.sep)
if __name__ == '__main__':
filepath = r'D:\00. Information \document-master\ Formal course materials '
print(convert_path(filepath))
get_files(filepath)

In this way, one click name change is supported .
边栏推荐
- Devsecops: s-sdlc enterprise best practices
- R&S示波器软件,罗德与施瓦茨示波器上位机软件NS-Scope介绍
- 有意思的鼠标指针交互探究
- 【100个 Unity踩坑小知识点】| Unity中的 碰撞盒检测 Physics.OverlapBox、OverlapCaps
- Is 100W data table faster than 1000W data table query?
- DevSecOps:S-SDLC企业最佳实践
- Deep water area involvement
- 2022年安全员-A证考试模拟100题及在线模拟考试
- 毕业季,说一说自己从学生初入职场的感受
- 当GDPR来敲门
猜你喜欢

2022 special operation certificate examination question bank and online simulation examination for safety management personnel of hazardous chemical business units

【哈尔滨工业大学】考研初试复试资料分享

Deep water area involvement

适配器电源自动测试设备|充电器ATE测试系统NSAT-8000介绍

Customization of power aging test system | overview of charging pile automatic test system nsat-8000

Getting started with data visualization

学者魔改 Qt Creator 插件框架(附实例)

2022年安全员-A证考试模拟100题及在线模拟考试

矩形覆盖面积

XML实体注入漏洞
随机推荐
Broken knowledge
Machine learning 2-linear regression
You must get started with boost
DevSecOps:S-SDLC企业最佳实践
Never ending database injection attack and defense
是德示波器软件,Keysight示波器上位机软件NS-Scope
fix libpng warning: iCCP: Not recognizing known sRGB profile ......
2022年安全员-A证考试模拟100题及在线模拟考试
Illustrated with pictures and texts -- wechat applet to obtain the user's geographic location information and call Tencent map API to obtain the user's specific location
Est le logiciel d'oscilloscope allemand, le logiciel d'ordinateur hôte d'oscilloscope keysight NS scope
碎知识...
贺志理:红树林湿地沉积物中微生物驱动的碳氮硫磷循环及其耦合机制
Design and implementation of server security audit system
What is the relationship between CSC securities and qiniu school? Is it safe to open a brokerage account
QML introduction to advanced
有意思的鼠标指针交互探究
电源老化测试系统定制|充电桩自动化测试系统NSAT-8000概述
Five steps to successfully complete threat modeling
中信建投券商是跟启牛学堂存在什么关系?开券商账户安全吗
完美安全代码审计的5个最佳实践