Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Starting all files/exes in a directory?  (Read 3185 times)

0 Members and 1 Guest are viewing this topic.

phobos2deimos

    Topic Starter


    Starter

    Starting all files/exes in a directory?
    « on: February 10, 2009, 04:54:37 PM »
    Hi All - First post here.  Trying to put together a batch file to make life a little easier.

    I'd like to make a batch file open all files and programs within a single folder on a mapped network drive.  These files and programs will change constantly, so I can't tell DOS the file names.
    For example, I've got a folder on c:\ called "test".  Inside of test I've got a url "digg.url" link and a shortcut to filemaker pro "fmp.lnk".  I want them to both open when I run "test.bat"
    I'm trying to use wildcards to make this happen. I thought it would be fairly straightforward.

     So far, I've got:

    cd c:\test
    start *.*

    I get "windows cannot find file *.*".

    I'm not experienced in dos - I can navigate and run a command here and there.

    Help is much appreciated.

    oldun

    • Guest
    Re: Starting all files/exes in a directory?
    « Reply #1 on: February 11, 2009, 04:01:29 AM »
    Maybe something like this?

    Code: [Select]
    @Echo Off
    CD /D C:\Test
    Dir /B > C:\Content.txt
    For /F "tokens=*" %%i In (C:\Content.txt) DO Start "" /WAIT %%i

    GuruGary



      Adviser
      Re: Starting all files/exes in a directory?
      « Reply #2 on: February 11, 2009, 08:55:24 AM »
      You can also do it without creating a content file (and without waiting) like this:
      Code: [Select]
      cd "C:\test"
      for /f "tokens=*" %%a in ('dir /a-d /b') do start "" "%%a"

      BC_Programmer


        Mastermind
      • Typing is no substitute for thinking.
      • Thanked: 1140
        • Yes
        • Yes
        • BC-Programming.com
      • Certifications: List
      • Computer: Specs
      • Experience: Beginner
      • OS: Windows 11
      Re: Starting all files/exes in a directory?
      « Reply #3 on: February 11, 2009, 08:57:44 AM »
      this will work in pure DOS:

      Code: [Select]
      cd C:\test
      for %%P in (*.exe) do start %%P
      I was trying to dereference Null Pointers before it was cool.

      phobos2deimos

        Topic Starter


        Starter

        Re: Starting all files/exes in a directory?
        « Reply #4 on: February 11, 2009, 12:22:41 PM »
        Thanks for your suggestions.  I'll give these a shot and update later.

        phobos2deimos

          Topic Starter


          Starter

          Re: Starting all files/exes in a directory?
          « Reply #5 on: February 12, 2009, 08:45:21 PM »
          We have a Winner!  (Almost).

          So I plugged in my original test values using a local drive.  Worked perfectly.
          I then plugged in my actual working values - instead of
          cd "C:\test"

          I put it to

          cd "Z:\test"

          Z being a shared drive on the domain that is mapped to the local machine.

          When I do that, the batch file defaults to the directory where the batch file is stored, and opens everything in that directory (including the batch file itself, which opens everything + itself, which creates a loop that ends up opening dozens of windows worth of the same thing).

          I have verified that I am connected and authenticated to the mapped drive.

          In the end, this .bat is only functional if it is able to grab its items from a mapped network drive. 

          Any ideas? I feel like I'm on the cusp of success.\

          Thanks in advance.

          You can also do it without creating a content file (and without waiting) like this:
          Code: [Select]
          cd "C:\test"
          for /f "tokens=*" %%a in ('dir /a-d /b') do start "" "%%a"



          GuruGary



            Adviser
            Re: Starting all files/exes in a directory?
            « Reply #6 on: February 12, 2009, 10:17:46 PM »
            If you are changing drive letters you need the /D switch on the CD (or manually change the drive letter).  So try this instead:
            Code: [Select]
            cd /D "C:\test"
            for /f "tokens=*" %%a in ('dir /a-d /b') do start "" "%%a"

            phobos2deimos

              Topic Starter


              Starter

              Re: Starting all files/exes in a directory?
              « Reply #7 on: February 13, 2009, 09:53:01 AM »
              It works perfectly.

              +3 internets, and the right to name my firstborn.

              Thanks!!

              patio

              • Moderator


              • Genius
              • Maud' Dib
              • Thanked: 1769
                • Yes
              • Experience: Beginner
              • OS: Windows 7
              Re: Starting all files/exes in a directory?
              « Reply #8 on: February 13, 2009, 09:54:35 AM »
              "Sparky".....

               ;D
              " Anyone who goes to a psychiatrist should have his head examined. "