58a8924811
Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
36 lines
1,021 B
Python
Executable file
36 lines
1,021 B
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
import datetime
|
|
import os
|
|
import os.path
|
|
|
|
DATETIMEFORMAT = "%Y-%m-%d-%H%M"
|
|
DISKFORMAT = DATETIMEFORMAT
|
|
|
|
|
|
basedir = os.environ['HOME']
|
|
ctt_dir = os.path.join(basedir, ".ctt")
|
|
|
|
for project in os.listdir(ctt_dir):
|
|
time_dir = os.path.join(ctt_dir, project)
|
|
for time in os.listdir(time_dir):
|
|
print("Converting dir %s/%s" % (project, time))
|
|
try:
|
|
import_time = datetime.datetime.fromtimestamp(int(time))
|
|
except ValueError as e:
|
|
print("No old style directory %s from project %s - skipping" % (time, project))
|
|
continue
|
|
|
|
new_dirname = import_time.strftime(DISKFORMAT)
|
|
|
|
print("%s -> %s" % (time, new_dirname))
|
|
src = os.path.join(ctt_dir, project, time)
|
|
dst = os.path.join(ctt_dir, project, new_dirname)
|
|
print("%s -> %s" % (src, dst))
|
|
|
|
if os.path.exists(dst):
|
|
print("Cannot overwrite dst: %s, skipping %s" % (dst, src))
|
|
continue
|
|
|
|
os.rename(src, dst)
|
|
|