Skip to content

Instantly share code, notes, and snippets.

@naoki-sawada
Last active August 8, 2017 02:51
Show Gist options
  • Save naoki-sawada/05b0a446012b31def2e16a73a8334cfb to your computer and use it in GitHub Desktop.
Save naoki-sawada/05b0a446012b31def2e16a73a8334cfb to your computer and use it in GitHub Desktop.
replace the file name.
import os
from shutil import copyfile
from pathlib import Path
SOURCE_PATH = '.'
DEST_PATH = './re'
d_path = Path(DEST_PATH)
if not d_path.is_dir():
os.makedirs(DEST_PATH)
files = os.listdir(SOURCE_PATH)
for file in files:
print(file)
copyfile(SOURCE_PATH+'/'+file, DEST_PATH+'/'+file.replace('-','_'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment