For example, you have a rename command in a batch file, and you want to execute that file on the current directory and all sub-directories.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Suppose your batch is named something like
myrename.cmd, then you can easily do the following:The first line will run it for the current directory, the
forloop will iterate recursively (/r) over all directories (/d) and execute the part in the parentheses. What we do inside them is change the directory to the one we’re currently iterating over withpushd—which has the nice property that you can undo that directory change withpopd—and then run the command, which then will be run in the directory we just switched to.This assumes that the batch lies somewhere in the path. If it doesn’t and just happens to lie where the batch file above lies, then you can use