Skip to content

Instantly share code, notes, and snippets.

@nakamura001
Created December 13, 2011 06:01
Show Gist options
  • Save nakamura001/1470824 to your computer and use it in GitHub Desktop.
Save nakamura001/1470824 to your computer and use it in GitHub Desktop.
指定フォルダ内の全ファイルをリネーム
#! /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