-3

I have several bat files on network. I like to create one bat so I can run all one time. Also I like to use *.bat in new bat so I don't need copy each bat files.

Marcus Müller
  • 27,924
  • 4
  • 40
  • 79
user1203397
  • 43
  • 1
  • 7
  • Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. – Marcus Müller Feb 10 '16 at 15:17
  • I have 5 bat files name 1.bat, 2.bat and so on. I don't want to run each bat file. I like to create one single bat file that can run all 5 bat files. More importance that in new bat file, I need to use wildcard so I don't need to add each bat file name but I like to use ( *.bat) to look for all bat files – user1203397 Feb 10 '16 at 15:19
  • Use the `FOR` command to iterate through all the .bat files in the directory and then use the CALL command to execute them. – Squashman Feb 10 '16 at 15:20
  • Please I need example – user1203397 Feb 10 '16 at 15:25

1 Answers1

-1

Using the FOR command you can locate files with a wildcard in the name and then run all of them in sequence.

FOR /F "usebackq " %%F in (`dir "%~dp0filename*.BAT`) DO Call "%~dp0%%~F"

This code will list all files that start with "filename" and end in ".bat" and then rin them. This use of the FOR command will work in folders with spaces in the name. It will even run from a UNC path (one that start with \ and is located on a network share).

CoveGeek
  • 425
  • 3
  • 10
  • If you are going to downvote me, especially on this answer, then you need to provide some feedback... – CoveGeek Feb 10 '16 at 19:55
  • my files are on net work like \\xx\ temp\file and not sure how to add on this FOR /F "usebackq " %%F in (`dir "%~dp0filename*.BAT`) DO Call "%~dp0%%~F" – user1203397 Feb 11 '16 at 14:46
  • @user1203397 you are missing the [`] which is the backquote under the ~. Without that character, it won't work. – CoveGeek Feb 11 '16 at 16:52