1. The variables used for the FOR loops were not cleared before use (initialized).
2. The FIND command was outputting some extraneous lines. Switched to FINDSTR and TYPE to input file.
3. Changed the tokens for the description FOR to grab entire description.
4. Personally I do not like using variables which match commands as these can cause bad results. Replaced varable Dir with Location.
5. Using C:FileName can give unexpected results. Always give path i.e. C:\, C:\Temp.
6. GOTO END may not give expected results. Use a defined lable or EXIT.
if not exist %Location% goto :DONE
for /f “tokens=1″ %%a in (‘type “%Location%*PO_FILE_*”^|findstr /i “LINEITEM”‘) do (
for /f “tokens=1,*” %%a in (‘type “%Location%*PO_FILE_*”^|findstr /i “LINDESC”‘) do (
echo !ITEM:~38,12! >> C:\Temp\ITEMLIST.txt
echo !DESC! >> C:\Temp\ITEMLIST.txt