Last active
July 20, 2025 10:26
-
-
Save g-rohit/4b7f5baabb6897a982d4060384302a9a to your computer and use it in GitHub Desktop.
Add file count to folder name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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