Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have a text file which is a log file it contains the below data
----------------------------------------------------------text file data------------------------------------------------------------------
Y:\>copy "Y:\Version 1\BCS\006\NT\BCS_NT_61006.zip" "C:\Distribute\6.1\6.1.006.75660\WIN\x86\DBCS"
1 file(s) copied.Y:\>copy "Y:\Version 2\BCS\007\NT\BCS_NT_61007.zip" "C:\Distribute\6.1\6.1.007.78630\WIN\x86\DBCS"
1 file(s) copied.Y:\>copy "Y:\Version 3\BCS\008\NT\BCS_NT_61008.zip" "C:\Distribute\6.1\6.1.008.79681\WIN\x86\DBCS"
1 file(s) copied.Y:\>copy "Y:\Version 4\BCS\009\NT\BCS_NT_61009.zip" "C:\Distribute\6.1\6.1.009.9002\WIN\x86\DBCS"
1 file(s) copied.Y:\>copy "Y:\Version 5\BCS\010\NT\BCS_NT_61010.zip" "C:\Distribute\6.1\6.1.010.9002\WIN\x86\DBCS"
1 file(s) copied.Y:\>copy "Y:\Version 1\BCS\022\NT\BCS_NT_61022.zip" "C:\Distribute\6.1\6.1.022.9002\WIN\x86\DBCS"
The system cannot find the file specified.Y:\>copy "Y:\Version 1\BCS\023\NT\BCS_NT_61022.zip" "C:\Distribute\6.1\6.1.022.9002\WIN\x86\DBCS"
The system cannot find the file specified.Y:\>copy "Y:\Version 1\BCS\024\NT\BCS_NT_61022.zip" "C:\Distribute\6.1\6.1.022.9002\WIN\x86\DBCS"
The system cannot find the file specified.Y:\>copy "Y:\Version 1\BCS\025\NT\BCS_NT_61022.zip" "C:\Distribute\6.1\6.1.022.9002\WIN\x86\DBCS"
The system cannot find the file specified.Y:\>copy "Y:\Version 1\BCS\026\NT\BCS_NT_61022.zip" "C:\Distribute\6.1\6.1.022.9002\WIN\x86\DBCS"
The system cannot find the file specified.Y:\>copy "Y:\Version 1\BCS\027\NT\BCS_NT_61022.zip" "C:\Distribute\6.1\6.1.022.9002\WIN\x86\DBCS"
The system cannot find the file specified.Y:\>copy "Y:\Version 1\BCS\028\NT\BCS_NT_61022.zip" "C:\Distribute\6.1\6.1.022.9002\WIN\x86\DBCS"
The system cannot find the file specified.Y:\>copy "Y:\Version 1\BCS\029\NT\BCS_NT_61022.zip" "C:\Distribute\6.1\6.1.022.9002\WIN\x86\DBCS"
The system cannot find the file specified.
----------------------------------------------------------text file data------------------------------------------------------------------
I want a batch script or command which returns a line containing the search string
I am doing like thisfindstr /b "The system Cannot" "c:\log.txt" > log.CSV
It is giving the output like the below one
The system cannot find the file specified.
The system cannot find the file specified.
The system cannot find the file specified.
The system cannot find the file specified.
The system cannot find the file specified.
The system cannot find the file specified.
The system cannot find the file specified.
The system cannot find the file specified.
but i want the output as
Y:\>copy "Y:\Version 1\BCS\022\NT\BCS_NT_61022.zip" "C:\Distribute\6.1\6.1.022.9002\WIN\x86\DBCS"
Y:\>copy "Y:\Version 2\BCS\023\NT\BCS_NT_61023.zip" "C:\Distribute\6.1\6.1.023.9004\WIN\x86\DBCS"
Y:\>copy "Y:\Version 3\BCS\024\NT\BCS_NT_61023.zip" "C:\Distribute\6.1\6.1.023.9004\WIN\x86\DBCS"
Y:\>copy "Y:\Version 4\BCS\025\NT\BCS_NT_61023.zip" "C:\Distribute\6.1\6.1.023.9004\WIN\x86\DBCS"
Y:\>copy "Y:\Version 5\BCS\026\NT\BCS_NT_61023.zip" "C:\Distribute\6.1\6.1.023.9004\WIN\x86\DBCS"
Y:\>copy "Y:\Version 6\BCS\027\NT\BCS_NT_61023.zip" "C:\Distribute\6.1\6.1.023.9004\WIN\x86\DBCS"
Y:\>copy "Y:\Version 6\BCS\028\NT\BCS_NT_61023.zip" "C:\Distribute\6.1\6.1.023.9004\WIN\x86\DBCS"
Y:\>copy "Y:\Version 6\BCS\029\NT\BCS_NT_61023.zip" "C:\Distribute\6.1\6.1.023.9004\WIN\x86\DBCS"Can you please help me.
Thanks.

@echo off > newfile & setLocal enableDELAYedexpansion
for /f "tokens=* delims= " %%a in (mylog) do (
set p=!c!
set c=%%a
echo !c! | find "The system cannot find the file specified" > nul
if not errorlevel 1 (
>> newfile echo !p!
)
)
=====================================
Helping others achieve escape felicityM2

@echo off & setlocal EnableDelayedExpansion type nul > output.txt set pre= for /F "delims=" %%j in ('type "TextFile.txt"') do ( set row=%%j set row=!row:the system cannot find=! if not "!row!"=="%%j" echo.!pre! set pre=%%j ) >> output.txt

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |