A project that aims to get rid of the time stamp after taking files out of file history on windows.
First(s) during this project
- Honestly trying idiomatic Python
- Project estimation, this was very difficult!
- Pylint and Python styling
- Large scale OS interactions via programs
What I learned:
- Python is awesome!
- Estimations are hard (planned for 3 hours, and actually used 6)
- Feature creep is a real thing (I thought I was done at hour 2)
- Refer to the first point
- Go with the flow (don’t “break the chain”)
I was switching between operating systems and decided to make a fresh install of Windows. I use the File History backup feature on an external drive. It’s great to have backups but when I copied everything over, all my files had odd timestamps associated with them. I knew due to the magnitude of the problem that I wouldn’t be trying to solve this issue with simple batch file scripting. I instead chose to more fun and versatile tool, Python.
Issues/Cases to keep in mind:
- Some files have been tracked through file history a few different times, they have two time stamps (shown below).
- If I modified a word document, saved it, and then ran file history there would be two copies of the file basically with the same name. The only differentiating factor would be the time stamp (shown below). I want my program to remove the older files.
- Some files have the Windows standard “(1)” placed at the end of the file name, I have to be sure that I’m not targeting those files.
- While renaming files I must keep their extensions intact. I can’t rename a word file and delete its “.docx” extension.
- All files when being copied out of File History are read only, as such I need to change that before I delete or rename any of the files.
I developed a program that used regular expressions and some very handy methods from the os module to complete my aims.
Features of my program:
- Recursively crawls the file system given a root directory
- Removes time stamps
- Ensures extensions remain intact
- Deletes “old” and “redundant” files.
- Makes all files both readable and writable
- Accurately targets time stamps (doesn’t get confused with “(1)” endings)
- Handles periods positioned within file names correctly
