Skip to content

Instantly share code, notes, and snippets.

@Penguin-Spy
Last active September 15, 2025 05:37
Show Gist options
  • Select an option

  • Save Penguin-Spy/bb11c8ce1257806a1775ea07b4ea94c2 to your computer and use it in GitHub Desktop.

Select an option

Save Penguin-Spy/bb11c8ce1257806a1775ea07b4ea94c2 to your computer and use it in GitHub Desktop.
batch script + registry keys to add a context menu option for tagging folders. to install: download & extract the zip (top right of this page), then run install-tag-folder.bat (say yes to the prompt, it's for adding the context menu item). after running the installer file you can delete it.
mkdir "C:\ProgramData\tag-folder"
move tag-folder.bat "C:\ProgramData\tag-folder"
tag-folder-shortcuts.reg
del tag-folder-shortcuts.reg
@echo.
@echo -------------------------------------
@echo tag-folder v1.0 has been installed!
@echo Copyright (c) 2022 Penguin_Spy
@echo.
@pause
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\tag-folder]
@="Tag current folder"
"Icon"="C:/WINDOWS/System32/shell32.dll,133"
[HKEY_CLASSES_ROOT\Directory\Background\shell\tag-folder\command]
@="cmd /c \"start C:/ProgramData/tag-folder/tag-folder.bat\""
[HKEY_CLASSES_ROOT\Directory\shell\tag-folder]
"Icon"="C:/WINDOWS/System32/shell32.dll,133"
@="Tag folder"
[HKEY_CLASSES_ROOT\Directory\shell\tag-folder\command]
@="cmd /c \"start C:/ProgramData/tag-folder/tag-folder.bat %1\""
:: tag-folder.bat v1.0
:: Copyright (c) 2022 Penguin_Spy
:: batch script to add a "Tag folder" context menu item
:: for use with https://gist.github.com/Penguin-Spy/bb11c8ce1257806a1775ea07b4ea94c2
:: based on: https://youtu.be/vyFhSdm4gD8
:: init & set size
@ECHO OFF
SETLOCAL
mode con: cols=60 lines=3
:: allow for the optional cmdline argument of the folder to take action on, default to current working directory
:: argument is used in folder context menu, default is used in "background" context menu
set target_folder=%*
if "%target_folder%"=="" set target_folder=%cd%
:: make sure the rest of the script executes in the target folder
cd %target_folder%
:: prompt
title Set tag
echo %target_folder%
set /P tag=Tag:
:: save all other contents of desktop.ini if it exists
if exist desktop.ini (
ATTRIB -h -s desktop.ini > NUL
TYPE desktop.ini|FINDSTR /V "F29F85E0 Prop5" > "%temp%\desktop.ini"
) else (
type nul > "%temp%\desktop.ini"
)
:: write new tag if one was specified
if not "%tag%"=="" (
ECHO [{F29F85E0-4FF9-1068-AB91-08002B27B3D9}] >> "%temp%\desktop.ini"
ECHO Prop5=31,%tag% >> "%temp%\desktop.ini"
)
:: move desktop.ini back & set attributes
move "%temp%\desktop.ini" "%cd%"
ATTRIB +h +s desktop.ini
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment