Paul C's Blog

To be funny,to grow up!

0%

增加时间戳脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

# coding: utf-8



import os
import time
import datetime



path=os.getcwd()
newpath="_posts"



def TimeStampToTime(timestamp):
timeStruct = time.localtime(timestamp)
return time.strftime('%Y-%m-%d %H:%M:%S',timeStruct)


def get_FileCreateTime(file):
t = os.path.getctime(file)
ctime=TimeStampToTime(t)
return ctime[0:10]



def rename_files(path):
filelist=os.listdir(path)
for file in filelist:
filename=file.split('.')
os.rename(file,filename[0]+'.md')
print(filename[0])

#def note_code(path):

rename_files(path)