@echo off :: This batch file will compile a list of all directories, :: change into each of the subdirectories, then run any :: command you pass it. If you don't pass it a command, it :: will just tell you the short name of the directories. :: Check if I can see myself. Needed so I can change :: back to my home directory. You should ALWAYS use full :: path and file name (like c:\utils\alldirs.bat) when :: running this program. Or you can double-click it or :: do drag'n'drops on it. if not exist %0 goto DONE :: Change to my home directory if I'm not there already %0\ cd %0\.. :: Make a line fragment :: See http://www.ericphelps.com/batch/lines/frag-dbg.htm echo e 100 "set dir="> script echo rcx>> script echo 8>> script echo n setdir.txt>> script echo w>> script echo q>>script debug < script > nul del script :: Now make a list of directories :: ************** Change the "\" to whatever you want *********** dir \ /ad /b /s | find /v ":\RECYCLED" > directories.txt :: Now process each line :LOOPSTART rem Check to see if directories.txt is zero bytes dir directories.txt | find "directories.txt" | find " 0 " > nul if not errorlevel 1 goto DONE copy /b setdir.txt + directories.txt directories.bat > nul rem Create a new directories.txt minus the first line type directories.bat | find /v "set dir=" > directories.txt rem Trim the bat file so it only has the first line type directories.bat | find "set dir=" > directories.bat call directories.bat rem Change to the indicated drive and directory "%dir%\" cd "%dir%" rem Run the desired program or TRUENAME if no program if [%1]==[] truename if not [%1]==[] %1 %2 %3 %4 %5 %6 %7 %8 %9 rem Change back to my home directory %0\ cd %0\.. goto LOOPSTART :DONE :: Clean up del setdir.txt > nul del directories.txt > nul del directories.bat > nul