Skip to content

Instantly share code, notes, and snippets.

@g-rohit
Last active July 20, 2025 10:26
Show Gist options
  • Save g-rohit/4b7f5baabb6897a982d4060384302a9a to your computer and use it in GitHub Desktop.
Save g-rohit/4b7f5baabb6897a982d4060384302a9a to your computer and use it in GitHub Desktop.
Add file count to folder name
@echo off
setlocal EnableDelayedExpansion
:: Set your root folder path
cd /d "C:\Path\To\Your\Folders"
for /d %%F in (*) do (
set "folderName=%%F"
set "fileCount=0"
:: Count files only (not subfolders)
for %%I in ("%%F\*") do (
set /a fileCount+=1
)
:: Rename folder by appending file count
ren "%%F" "!folderName! [!fileCount! files]"
)
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment