Skip to main content

Introduction

The touch command is commonly used in Unix/Linux environments to change the Date Modified value of a file. It can also be useful when working with GitHub as it enables you to run a commit again without having to use complicated git commands.

retouch is a variant of touch that works specifically with our Docusaurus/VS Code setup. What it does is change the timestamp of all .md files that have been modified recently.

For example, you have spent the morning until lunch adjusting text in some files. A commit fails, and you want to run it again, but VS Code thinks it has already processed those files. Normally, you would go through all those files and make a small change in them so that the next commit picks them up again.

retouch automates that and lets you "reset" all files that you changed in the last 4 hours.

Usage

retouch is a Python script, so in order to run it, Python 3 must be installed. It can be done by downloading and running the installer from https://www.python.org/downloads/.

After that, the command can be run either from a normal CMD prompt or from VS Code's Terminal (recommended). The syntax is:

python ./retouch.py [minutes] [hours:minutes] [year-month-day]

In the example above, we wanted to reset all the files that had been modified within the last 4 hours. The easiest way is to give the number of minutes (4 * 60 = 240) as an argument:

python ./retouch.py 240

The script will search through the /docs folder and its content for all .md files that fit the criteria and show a list with matching names:

large

If the list looks okay, type Y and press Enter. The files will be processed:

large

Instead of having to calculate the number of minutes, we can also give the argument in the format of [hour]:[minutes]. Example: we want to reset all files that have been changed in the last 6 hours and 30 minutes:

python ./retouch.py 6:30

It's possible to use a date format as well: year-month-day. Example: if we want to process all files changed since March 12, 2024:

python ./retouch.py 2024-03-12