Skip to content

Instantly share code, notes, and snippets.

@m-note
Last active November 1, 2015 01:27
Show Gist options
  • Save m-note/db3f07bca84ebd97cf1d to your computer and use it in GitHub Desktop.
Save m-note/db3f07bca84ebd97cf1d to your computer and use it in GitHub Desktop.
import sys
import os
import re
if __name__ == "__main__":
folder = input("Folder pass: ")
file_list = os.listdir(folder)
os.chdir(folder)
for file in file_list:
pattern = re.compile(r".csv")
if pattern.search(file):
name_temp = file[ : -7] # "_p1.csv"となっているところを置き換えるので、それを除く
new_name = name_temp + "_p2.csv"
os.rename(file, new_name)
else:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment