30 lines
730 B
Python
30 lines
730 B
Python
import os
|
|
from os.path import isfile, isdir
|
|
|
|
path = "/Volumes/home/Photos/Moments/Sorted"
|
|
rootlist = os.listdir(path)
|
|
print(rootlist)
|
|
|
|
renameMap = {
|
|
"Jan": "01",
|
|
"Feb": "02",
|
|
"Mar": "03",
|
|
"Apr": "04",
|
|
"May": "05",
|
|
"Jun": "06",
|
|
"Jul": "07",
|
|
"Aug": "08",
|
|
"Sep": "09",
|
|
"Oct": "10",
|
|
"Nov": "11",
|
|
"Dec": "12"
|
|
}
|
|
|
|
for year in rootlist:
|
|
if not year == '.DS_Store':
|
|
yearFolder = os.listdir(path + "/" + year)
|
|
print(yearFolder)
|
|
for month in yearFolder:
|
|
if not month == '.DS_Store':
|
|
#print(path + "/" + year + "/" + renameMap[month])
|
|
os.rename(path + "/" + year + "/" + month, path + "/" + year + "/" + renameMap[month] ) |