简体   繁体   中英

Need batch file to open all .XLSM files in a folder one at a time (open next after previous closes)

I have a folder with 100+ .XLSM files. They are each set to auto-run a sequence, save and close when opened. I currently have a batch file set to open each file in the folder. However, I've only been able to set a "delay" before opening the next file. Some of the files take 10 seconds to run the sequence and close, and some take about 50 seconds, so I have to set the "delay" at 50 second pause for all files. I am looking for a way to set the files to open One-At-A-Time, and open the next file as soon as the previous file has closed, instead of having to wait the full 50 seconds for each.

Here is the current batch file I am using...

@echo off 

for %%x in (C:\...\*.xlsm) do (

  start %%x

  timeout /t 50 /nobreak >nul

)

I've seen suggestions to use the /wait cmd, but it wasn't clear and I couldn't get it to work. I know very little on how to use batch files. Thanks for any help or suggestions.

Try ;

@echo off
for %%x in (C:\...\*.xlsm) do (
  echo Starting.. %%x
  start "" /wait %%x
)

I tested with my *.mp4 files i belive it will work with *.xlsm files also.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM