Created
August 12, 2014 11:27
-
-
Save ikekou/768e83a7631ce3826031 to your computer and use it in GitHub Desktop.
ディレクトリにあるph_001.jpgっていうファイルを1.jpgにリネームする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import os | |
import sys | |
import os.path | |
dir = './' | |
files = os.listdir(dir) | |
for file in files: | |
print '--' | |
src=file | |
if(src[0]=='.'): | |
continue | |
if(src==__file__): | |
continue | |
dist=src.replace('ph_','') | |
name,ext=dist.split('.')\ | |
dist2=str(int(name))+'.'+ext | |
print(dist2) | |
os.rename(src,dist2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment