Skip to content

Instantly share code, notes, and snippets.

@tridevgurung
Created July 29, 2015 11:00
Show Gist options
  • Save tridevgurung/a86b00b17207132b43aa to your computer and use it in GitHub Desktop.
Save tridevgurung/a86b00b17207132b43aa to your computer and use it in GitHub Desktop.
Batch file to count the number of files and making a text file upon it.
echo OFF
:: Delayed Expansion causing variables to exanded at execution time rather than at parse time
setlocal enabledelayedexpansion
dir /ad /b > tel2.txt
::Entering in Day Folder
for /F "tokens=*" %%j in (tel2.txt) do (
cd "%%j"
echo "%%j"
dir /ad /b > tel1.txt
::Entering in Event Folder
for /F "tokens=*" %%j in (tel1.txt) do (
cd "%%j"
echo "%%j"
::Listing all the Image Folders
dir /ad /b > tel.txt
::Entering in Image Folders
for /F "tokens=*" %%i in (tel.txt) do (
echo "%%i"
cd "%%i"
::Making list of all the jpg files
dir /b *.jpg | find /v /c "*.jpg" > temp.txt
set /p t=< temp.txt
echo !t!
del *.txt
::Making z_image_count_ file according to the number of jpg files
type NUL > z_image_count_!t!.txt
cd .. )
del tel.txt
cd ..)
del tel1.txt
cd ..)
del tel2.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment