diff options
| author | Teddy Wing | 2018-06-28 01:30:25 +0200 |
|---|---|---|
| committer | Teddy Wing | 2018-06-28 01:30:25 +0200 |
| commit | ff2c02f50b3ee9f63a3fc5986ebb3a938247ae79 (patch) | |
| tree | 53477261bf2e015724b7dd887529cd1075cdba5e | |
| download | glyphs-typarichive-ff2c02f50b3ee9f63a3fc5986ebb3a938247ae79.tar.bz2 | |
Initial version with file handling
Copies the current font and updates the timestamp in its filename. Moves
the current font to the `_archive` directory, closes it in Glyphs, and
opens the new font file with the new timestamp.
| -rw-r--r-- | typarichive.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/typarichive.py b/typarichive.py new file mode 100644 index 0000000..e62eda5 --- /dev/null +++ b/typarichive.py @@ -0,0 +1,41 @@ +# MenuTitle: TypArichive + +__doc__=""" +TODO +""" + +from datetime import datetime +from os import path +import re +import shutil + +def new_font_name(filename): + time_string = datetime.now().strftime('%Y%m%d%H%M') + + return re.sub(r'\d{12}', time_string, filename) + +font = Glyphs.font +filepath = font.filepath + +# Glyphs.font.close() + + +font_directory = path.dirname(filepath) +archive_directory = path.join(font_directory, '_archive') +new_font_path = path.join( + font_directory, + new_font_name( + path.basename(filepath))) + +shutil.copy2(filepath, new_font_path) + +shutil.move(filepath, archive_directory) + +font.close() +Glyphs.open(new_font_path) + +# Close font +# Copy font file to new file +# Move old file to archive +# Open new file +# Rename font name with current timestamp |
