[Python]批量重命名,修改文件名中的部分字符串
上一版PowerShell版本的莫名其妙的有些改不了:https://www.cnblogs.com/alfredsun/p/10124230.html
![[Python]批量重命名,修改文件名中的部分字符串 [Python]批量重命名,修改文件名中的部分字符串](https://cdn.ancii.com/article/image/v1/sw/wV/kP/PkwwVsGDmjDG9swnOi7SkjVAsMQAarn73E9S3mmSmcDdrNX6in81D2ka2DuvwdsHxpkvOpK2JbH1ofw7Wh3Mhw.png)
更新一个Python版本:
import os
files = os.listdir(os.getcwd())
for file in files:
os.rename(file,file.replace(‘FLAC‘,‘FLACx2‘))效果:
![[Python]批量重命名,修改文件名中的部分字符串 [Python]批量重命名,修改文件名中的部分字符串](https://cdn.ancii.com/article/image/v1/sw/wV/kP/PkwwVsGDmjDG9swnOi7SkjVAsMQAarn73E9S3mmSmcDdrNX6in81D2ka2DuvwdsHUifSQ4Bd_iemBYSgBEaxwg.png)
上一版PowerShell版本的莫名其妙的有些改不了:https://www.cnblogs.com/alfredsun/p/10124230.html
![[Python]批量重命名,修改文件名中的部分字符串 [Python]批量重命名,修改文件名中的部分字符串](https://cdn.ancii.com/article/image/v1/sw/wV/kP/PkwwVsGDmjDG9swnOi7SkjVAsMQAarn73E9S3mmSmcDdrNX6in81D2ka2DuvwdsHxpkvOpK2JbH1ofw7Wh3Mhw.png)
更新一个Python版本:
import os
files = os.listdir(os.getcwd())
for file in files:
os.rename(file,file.replace(‘FLAC‘,‘FLACx2‘))效果:
![[Python]批量重命名,修改文件名中的部分字符串 [Python]批量重命名,修改文件名中的部分字符串](https://cdn.ancii.com/article/image/v1/sw/wV/kP/PkwwVsGDmjDG9swnOi7SkjVAsMQAarn73E9S3mmSmcDdrNX6in81D2ka2DuvwdsHUifSQ4Bd_iemBYSgBEaxwg.png)