for loop - Finding a certain file inside each directory in a set of directories using batch? -


This is my script. In this case I am trying to do the last file in the directory (when sorting alphabetically). Whenever I run it, the final file is given at every frequency in the 6th folder. What is wrong with this script? @echo closed cd folder1 \ folder 2 for / d %% g (*) (echo %% g for CD %% g / f %% f ('/ B / ad / on ') Do (final = %% set up)% dcho% last% cd .. pause) cd .. cd ..

This works like this:

Put it in your working directory and run it. $ / = $% = ~% F% for

  @echo off setlocal EnableDelayedExpansion for / ($ Dir / s / b / ad / on "%% a" '') % ~ XF "Echo of the last %% one! $ Is the last!) Echo finished ... Pause   

Edit:

Make your code work For:

  @echo offlocal for EnableDelayedExpansion (*) in D %% G (resonance %% g CD %% G \ for / f "delims =" %% F in ( 'Dir / b) / Ad / on') Do (set to last = %%) Echo! Last! Cd .. pause) cd .. cd ..    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -