Skip to content

Instantly share code, notes, and snippets.

@surgicalmaskman
Created June 26, 2017 06:54
Show Gist options
  • Save surgicalmaskman/46d2c9b337ef1f4b1989f64b323ac1b2 to your computer and use it in GitHub Desktop.
Save surgicalmaskman/46d2c9b337ef1f4b1989f64b323ac1b2 to your computer and use it in GitHub Desktop.
replace file name for ISO8601 standard to ISO 8601 extended
#! /bin/env python
# -*- coding:utf-8 -*-
import os
files= os.listdir(os.getcwd())
for i in range(len(files)):
if files[i].isdigit()== True:
print(files[i])
tmp= files[i]
yr= tmp[:4] + '-' + tmp[4:]
new= yr[:7]+ '-' + yr[7:]
os.rename(files[i], new)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment