-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclaireFileProcess.py
More file actions
35 lines (26 loc) · 949 Bytes
/
Copy pathclaireFileProcess.py
File metadata and controls
35 lines (26 loc) · 949 Bytes
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
"""
This file renames claire's audio files to sort them by the
date they were recorded.
This file must be in the dir with audio files.
Audio files must be 39 chars long.
resource: http://stackoverflow.com/questions/2759067/rename-files-in-python
"""
import os
name_dic = {}
for filename in os.listdir("."):
if len(filename) == 39:
count = ""
date = filename[22:30]
year= date[6:]
month= date[:2]
day= date[3:5]
string = "{}-{}-{}".format(year, month, day)
if string in name_dic:
name_dic[string] += 1
if string not in name_dic:
name_dic[string] = 1
if name_dic[string] != 1:
#string = (string + "_") + str(name_dic[string])
count = "p"+ str(name_dic[string])
string = "{}{}.mp3".format(string, count)
os.rename(filename, string)