Created
December 13, 2011 06:01
-
-
Save nakamura001/1470824 to your computer and use it in GitHub Desktop.
指定フォルダ内の全ファイルをリネーム
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
#! /usr/bin/env python | |
# coding: utf-8 | |
# 指定フォルダ内の全ファイルをリネーム | |
import os,re,sys | |
import tempfile | |
import shutil | |
in_dir = "org" | |
out_dir = "rename" | |
count = 0 | |
for (root, dirs, files) in os.walk(in_dir): | |
for f in files: | |
d, ext = os.path.splitext(f) | |
if ext == '': | |
continue | |
in_file = os.path.join(in_dir, f) | |
out_file = os.path.join(out_dir, "%02d%s" % (count, ext)) | |
print in_file | |
print out_file | |
print "" | |
shutil.copy(in_file, out_file) | |
count = count + 1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment