1.

Solve : how put a file list into a variable (string)?

Answer»

Hi All:

I NEED read a list of files from a directory and put into a VARIABLE (string) for use.

I have by example 3 files: "arch1.pdf" "arch2.pdf" "arch3.pdf"

I want put this string "arch1.pdf arch2.pdf arch3.pdf" in a variable.

I try with this sentences but not work.

echo off
for /f %%a in ('dir /b *.pdf') do (
set txt=%%a
echo %txt%
)
pause

what about:
Code: [Select]echo off
for /f %%a in ('dir /b *.pdf') do (
set txt=%txt% %%a
echo %txt%
)
pauseI try but the RESULT of the SCRIPT posted by BC_Programmer is:

txt
txt
txt



can you post the code for the batch file? Code: [Select]echo off
setlocal enabledelayedexpansion

for /f %%a in ('dir /b *.pdf') do (
set txt=!txt! %%a
echo !txt!
)
pause
?Perfect ... the last script work fine...   

thanks for everything...



Discussion

No Comment Found