1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

How to load a file in a program from batch file

Discussion in 'All Other Software' started by sososm, Jan 24, 2011.

Thread Status:
Not open for further replies.
  1. sososm

    sososm Thread Starter

    Joined:
    Nov 30, 2010
    Messages:
    6
    Hy there
    I want to load a file in a program from a batch file, problem is that I don't know the name of the file so I need something like:

    ========================================
    @echo off
    start c:\Program Files\Sound Forge\Forge.exe d:\*.wav
    ========================================
    so if there is a way to load a file without knowing the name i''ll apreciate it
    Thanks for your time in advance.
     
  2. TheOutcaste

    TheOutcaste

    Joined:
    Aug 7, 2007
    Messages:
    9,028
    The program would have to support loading files using a wildcard, or by specifying a folder of files to load.

    If it doesn't, you could use a For loop to generate a list of file names to be used in the Start command.

    This will pass the complete path for each file located in one folder. It does not get filenames from subfolders:
    Code:
    @Echo Off
    Set _List=
    Set _Folder=D:\
    Push %_Folder%
    For /F "Tokens=* Delims=" %%I In ('Dir "%_Folder%\*.wav" /A-D /B') Do Call _Build "%%~I"
    Start "" "C:\Program Files\Sound Forge\Forge.exe" %_List%
    Goto :EOF
    :_Build
    Set _List=%_List% "%~f1"
    
    You are limited to 8191 characters per line, so depending on where the files are, you can quickly reach that. The start command uses 65 characters leaving 8126 for the files in the list.
    For example, if the files are in C:\Documents and Settings\Administrator\My Documents\My Music\Samples\, that will use 70 characters per file, plus the length of the file name. Assuming only 11 characters per name, + 3 characters per file for quotes and a space between names, you'd be limited to 96 files.

    This version switches to the folder containing the files so you don't need to specify the path, but some programs might not like having the working folder changed:
    Code:
    @Echo Off
    Set _List=
    Set _Folder=D:\
    Push %_Folder%
    For /F "Tokens=* Delims=" %%I In ('Dir "%_Folder%\*.wav" /A-D /B') Do Call _Build "%%~I"
    Start "" /D "%_Folder%" "C:\Program Files\Sound Forge\Forge.exe" %_List%
    Goto :EOF
    :_Build
    Set _List=%_List% "%~nx1"
    
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/976680

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice