In BAT script, construct a PATH-like var from all the files in a specific directory - Programmer

This is a discussion on In BAT script, construct a PATH-like var from all the files in a specific directory - Programmer ; I previously asked about getting the output of a command into a variable. I'm going to be more specific about what I'm trying to do, in case there's a different way to do this. I'm constructing a PATH-like variable, with ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: In BAT script, construct a PATH-like var from all the files in a specific directory

  1. In BAT script, construct a PATH-like var from all the files in a specific directory

    I previously asked about getting the output of a command into a
    variable. I'm going to be more specific about what I'm trying to do,
    in case there's a different way to do this.

    I'm constructing a PATH-like variable, with file names separated by
    ";". I need to construct this with the full path to every file in a
    specific directory. Building the string was easy to do in Perl, but
    perhaps there's no way to get it back to the BAT script.

    Searching through some FAQs, I noticed that perhaps some variation of
    the "FOR" command might be able to do this. I've tried numerous
    variations, trying to use the "usebackq" option, to execute my perl
    script, for instance, or to execute "dir/b". I can't figure out how to
    make it execute the perl script with this, and "dir/b" doesn't quite
    work, as it doesn't print the full path for each file, and I can't
    figure out how to accumulate the values.


  2. Re: In BAT script, construct a PATH-like var from all the files ina specific directory

    davidmichaelkarr@gmail.com wrote:

    > I previously asked about getting the output of a command into a
    > variable. I'm going to be more specific about what I'm trying to do,
    > in case there's a different way to do this.
    >
    > I'm constructing a PATH-like variable, with file names separated by
    > ";". I need to construct this with the full path to every file in a
    > specific directory. Building the string was easy to do in Perl, but
    > perhaps there's no way to get it back to the BAT script.
    >
    > Searching through some FAQs, I noticed that perhaps some variation of
    > the "FOR" command might be able to do this. I've tried numerous
    > variations, trying to use the "usebackq" option, to execute my perl
    > script, for instance, or to execute "dir/b". I can't figure out how to
    > make it execute the perl script with this, and "dir/b" doesn't quite
    > work, as it doesn't print the full path for each file, and I can't
    > figure out how to accumulate the values.
    >


    Perhaps you can use the first answer that I just posted. On the other
    hand, I think (without testing) that this does what you want without
    using Perl.

    SET RESULT=
    FOR /F %p IN (wildcard) DO (
    CALL :APPEND_FILE_NAME %~fp
    )
    ....
    GOTO :EOF
    ....
    :APPEND_FILE_NAME
    IF "%RESULT%" == '' (
    SET RESULT=%*
    ) ELSE (
    SET RESULT=;%*
    )
    GOTO :EOF

    Norm

    --
    --
    To reply, change domain to an adult feline.


+ Reply to Thread