当前位置:网站首页>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 .
边栏推荐
- Flink tuning (I) resource tuning and back pressure analysis
- Matrial3d parameter analysis
- 秘密法宝
- 【yolov5s目标检测】opencv加载onnx模型在GPU上进行推理
- Shell process control - 35. Multi branch case conditional statements
- 考研政英平均分出炉!你目前什么水平?
- Devsecops: ten things that should be done well
- Runaway player
- It is the German oscilloscope software and the keysight oscilloscope upper computer software ns-scope
- 碎知识...
猜你喜欢

It is the German oscilloscope software and the keysight oscilloscope upper computer software ns-scope

fix libpng warning: iCCP: Not recognizing known sRGB profile ......

Getting started with data visualization

IMU选型、标定误差分析、AHRS组合导航

Est le logiciel d'oscilloscope allemand, le logiciel d'ordinateur hôte d'oscilloscope keysight NS scope

1108. IP 地址无效化

泰克Tektronix示波器上位机软件NS-Scope介绍

国宝上新计划-四大博物馆独家数字珍藏强势来袭!

重磅,MapStruct 1.5 发布,这次终于支持Map转为Bean了!

Heavyweight, mapstruct 1.5 was released. This time, it finally supports the transformation of map into bean!
随机推荐
ACM. HJ36 字符串加密 ●●
考研政英平均分出炉!你目前什么水平?
【100个 Unity实用技能】| 游戏中获取鼠标点击的坐标,并将游戏对象移动到鼠标的点击位置
Devsecops: s-sdlc enterprise best practices
清除交换机配置、配置镜像端口以及Wireshark抓包(以Huawei S5720为例)
华为云发布桌面IDE-CodeArts
数据可视化入门
碎知识...
服务器被入侵了怎么办
harmonyos培训一
中国企业海外业务DDoS防护探索
Break down tasks
qt对sqlite数据库多线程的操作
fix libpng warning: iCCP: Not recognizing known sRGB profile ......
Design and implementation of server security audit system
100w的数据表比1000w的数据表查询更快吗?
Factory mode implementation
学者魔改 Qt Creator 插件框架(附实例)
Operation control entry to Fang Si
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