Get list of files in specified directories

  • Thread starter Thread starter MVB
  • Start date Start date
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
 
"MVB" <madhurabhangay@yahoo.com> wrote in message
news:f22fb18a-312a-458d-8fad-d7a51c98ac77@e23g2000prf.googlegroups.com...
> 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
 
Back
Top