Get list of files in specified directories

M

MVB

Hi All,
I want to get a list of files from specified list of folders. I have
written following script but it is not working.
--------------------------------------------------------------------------------------------------------------------------------------
@echo off
SetLocal EnableExtensions EnableDelayedExpansion
rem # List of folders to be serched
set FOLDER_ARRAY=abc, def, xyz

rem # Get the folder list
FOR %%G IN (%FOLDER_ARRAY%) DO (
set folder=%%G

rem # Find files as *.orig in the specified folder
FOR /R !folder! %%F IN (*.orig) DO (
echo %%F
)
)
endlocal
--------------------------------------------------------------------------------------------------------------------------------------
In above script if I "echo !folder!" it is giving proper results but
it is not expanding properly in the second for loop.
Can anyone help me in this.
Thanks
MVB
 
P

Pegasus \(MVP\)

MVB said:
Hi All,
I want to get a list of files from specified list of folders. I have
written following script but it is not working.
--------------------------------------------------------------------------------------------------------------------------------------
@echo off
SetLocal EnableExtensions EnableDelayedExpansion
rem # List of folders to be serched
set FOLDER_ARRAY=abc, def, xyz

rem # Get the folder list
FOR %%G IN (%FOLDER_ARRAY%) DO (
set folder=%%G

rem # Find files as *.orig in the specified folder
FOR /R !folder! %%F IN (*.orig) DO (
echo %%F
)
)
endlocal
--------------------------------------------------------------------------------------------------------------------------------------
In above script if I "echo !folder!" it is giving proper results but
it is not expanding properly in the second for loop.
Can anyone help me in this.
Thanks
MVB

Try this simplified version:

@echo off
rem # List of folders to be searched
set FOLDER_ARRAY=abc, def, xyz

rem # Get the folder list
FOR %%G IN (%FOLDER_ARRAY%) DO dir %%G\*.orig
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top