0

I need a .bat and .sh script to list the all the *.xml files from source folder into one csv/txt file and copy csv/txt file into destination folder.

@ECHO OFF
NET USE X: /DELETE
NET USE X: \\SERVER\TEST
setlocal ENABLEDELAYEDEXPANSION
echo. > X:\XML_Response\xml_file_list.csv
set searchid="%<OrderNumber>"
for /f %%a in ('findstr /i /m %searchid% X:\XML_Response\*.xml') do (
  echo %%a >> X:\XML_Response\xml_file_list.csv
)
NET USE X: /DELETE

Above code give me list of files with path. I just want to have filenames.

X:\XML_Response\SO2001.xml 
X:\XML_Response\SO2002.xml 

I need only

SO2001.xml
SO2002.xml

Can anyone help

Abhijit
  • 13
  • 10

1 Answers1

0

You could shorten your script and still output what you asked for.

@PushD \\SERVER\TEST\XML_Response
@FindStr/MILC:"<OrderNumber>" *.xml>xml_file_list.csv
Compo
  • 36,585
  • 5
  • 27
  • 39
  • thanks. Could you please suggest what should be the script if we don't need to search for string , just find and list all the xml files from the folder. – Abhijit Jan 06 '18 at 09:43
  • After almost three weeks, the least you could have done was to mark the answer as accepted, not to ask a completely different question. Change line `2` to `@Dir /B/A-D-L *.xml>"xml_file_list.csv"`. – Compo Jan 06 '18 at 11:43