Ask Question Forum:
Model Library:2025-02-08 Updated:A.I. model is online for auto reply question page
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by Wass_QA
at 2024-09-05 05:48:12
Point:500 Replies:7 POST_ID:829218USER_ID:11914
Topic:
Windows Batch Scripting;VB Script;Visual Basic Programming
Hello,
Can you please help,
I have few .txt files in a specific Directory.
C:UsersWassim\__Task_Schedules\_Files_FTP
I need to Remove lines from text files that contains
qlcmd:
or
Error:
and save the file again. (same name)
thank you
Can you please help,
I have few .txt files in a specific Directory.
C:UsersWassim\__Task_Schedules\_Files_FTP
I need to Remove lines from text files that contains
qlcmd:
or
Error:
and save the file again. (same name)
thank you
Author: Wass_QA replied at 2024-09-05 16:07:40
Super,
thanks again.
thanks again.
Accepted Solution
Expert: Qlemo replied at 2024-09-05 15:45:21
500 points EXCELLENT
#@~! There is another typo in my code. You should have seen error messages hinting towards that. This time the code is tested:
@echo offfor /F "tokens=*" %%F in ('findstr /m "qlcmd: Error:" C:UsersWassim\__Task_Schedules\_Files_FTP*.txt ') do ( findstr /v "qlcmd: Error:" "%%~F" > "%%~F.$$$" move /y "%%~F.$$$" "%%~F") 1:2:3:4:5:
Expert: rwniceing replied at 2024-09-05 14:07:52
You can try this using forfiles to search all txt file at your directory (or some other dir such as "c:" including sub-directory with /s option), and save command out in junk.txt file and do the findstr search for "qlcmd: Error:" for each file from junk.txt file list, and finding output is saved with the same file name. If you need sub-folder search, just add "/s" option on forfiles command, and more forfiles details you can find it at http://ss64.com/nt/forfiles.html
@echo offforfiles /p "C:UsersWassim\__Task_Schedules\_Files_FTP" /m *.txt /C "cmd /c echo @path ">junk.txtecho -------Start-------------------------for /f "tokens=1 delims=" %%F in ('type C:UsersWassim\__Task_Schedules\_Files_FTP junk.txt') do (set "findtxt=qlcmd: Error:"set inputfile=%%Fset "outputfile=tempfile" if exist !outputfile! del !outputfile! for /f "delims=" %%i in ('findstr /v "%findtxt%" !inputfile!') do ( set "line=%%i" setlocal enabledelayedexpansionecho !line!>>"!outputfile!" endlocal)if exist !outputfile! ( copy !outputfile! !inputfile! echo Message:Success !inputfile! del !outputfile! ) else ( echo NOTE: Nothing done ) )REM del junk.txtecho -------Batch file Done------------------------- 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:
Author: Wass_QA replied at 2024-09-05 08:44:13
Hi Qlemo,
sorry, still not working,
is it because I have other texts on the same line?
thanks,
sorry, still not working,
is it because I have other texts on the same line?
thanks,
Expert: Qlemo replied at 2024-09-05 08:34:41
Sorry, forgot to remove something:
@echo offfor/F "tokens=*" %%F in ('findstr "qlcmd: Error:" C:UsersWassim\__Task_Schedules\_Files_FTP*.txt ') do ( findstr /v "qlcmd: Error:" "%%~F" > "%%~F.$$$" move "%%~F.$$$" "%%~F" /y) 1:2:3:4:5:
The search is case sensitive, as I think that is your intention.
Author: Wass_QA replied at 2024-09-05 08:09:05
Hi Qlemo,
Thanks for your help,
Nothing changed when I run the batch.
lines with qlcmd: or Error: are still there
thanks,
Thanks for your help,
Nothing changed when I run the batch.
lines with qlcmd: or Error: are still there
thanks,
Expert: Qlemo replied at 2024-09-05 07:42:55
@echo offfor/F "tokens=*" %%F in ('findstr /v "qlcmd: Error:" C:UsersWassim\__Task_Schedules\_Files_FTP*.txt ') do ( findstr /v "qlcmd: Error:" "%%~F" > "%%~F.$$$" move "%%~F.$$$" "%%~F" /y) 1:2:3:4:5:
We are using findstr twice to make sure we do not touch files not containing those lines.