At work I regularly need to share files with others over time through email. This happens a lot with pdfs and zipped files that are generated outputs of design documents. To help the recipients distinguish between a version of a file I sent last week vs today I often modify prepend the file name with the date. For example, the document schematic.pdf
becomes 210521 schematic.pdf
. And if I'm sending a second update for the day it'll be 210521b schematic.pdf
. Oh man, what a pain that is to manually do.
This program automates this process. An option to version a file is added to the file explorer right click context menu.
Assuming today is May 21st, 2021
schematic.pdf
->210521 schematic.pdf
210521 schematic.pdf
->210521b schematic.pdf
210521b schematic.pdf
->210521c schematic.pdf
200521 schematic.pdf
-> prompt to confirm you want to reversion. If yes the result is210521 schematic.pdf
. If no the file is unchanged200521q schematic.pdf
-> prompt to confirm you want to reversion. If yes the result is210521 schematic.pdf
. If no the file is unchanged
The last two items with prompts are cases that I don't see myself encountering, I don't revision already visioned files but I included them for the sake of completeness.
- Pull git repo or download file to a directory.
- Open regedit
- Under HKEY_CLASSES_ROOT/*/shell add a key and name it something descriptive such as VersionFile.
- Enter the text you'd like to see in the right click context menu in the (Default) key value
- Create a key under the key you just created and name it command
- Change the (Default) key value to
PATH_TO_PYTHON\python.exe "PATH_TO_PROGRAM\version-file.py" "%1"
This adds the option to the context menu for files. If you'd like to have the same option for directories follow the same process for HKEY_CLASSES_ROOT/Directory/shell.
If there are two files: 210521 schematic.pdf
and 200521 schematic.pdf
and you attempt to version the 200521 file it will prompt you to confirm you want to rename the file to 210521 schematic.pdf
. If you say yes nothing will happen and you won't be informed. I'm ok with this.
Should 26 versions of a file be generated in a single day and you get all the way up to 210521z schematic.pdf
, the next version will be 210521{ schematic.pdf
. The version after that will be 210521 210521{ schematic.pdf
because of the way the regular expressions work.
If your file happens to have six digits, 0 to 1 a-z characters, and a space at the beginning of the filename for whatever reason, the program has no way of knowing it's not an already versioned file. The most likely outcome is the prompt that the file is versioned at a different date asking if you want to change it to the current date.
Doesn't work on files/folders that require administrator access to edit. I'm not sure how to make this work.
At minimum, the prompts are windows only.