zoukankan      html  css  js  c++  java
  • 批量更改文件名

      下载了一些歌曲,其中有部分的名字是这样的 ”01.英雄谁属“

      需要删除掉 ”01.”的前缀,手动改太麻烦,参考网络上的资料写了个python代码:

    Python语言: Codee#26054
    01 import os
    02 path = "D:\\test"
    03 for item in os.listdir(path):
    04     old = item
    05     if item[0].isdigit():
    06         item = item[1:]
    07     if item[0].isdigit():
    08         item = item[1:]
    09     if item[0] == '.':
    10         item = item[1:]
    11     print item
    12     old = path + '/' + old
    13     item = path + '/' + item
    14     if old != item:
    15         os.rename(old,item)
  • 相关阅读:
    浅谈生成全排列的4种方法
    UVA
    UVA
    UVA
    UVA
    MySQL索引篇
    MySQL事务篇
    MySQL架构篇
    Redis性能调优
    Redis分布式锁
  • 原文地址:https://www.cnblogs.com/invisible/p/2447083.html
Copyright © 2011-2022 走看看