Search found 198 matches

by goodywp
13 Apr 2018 09:37
Forum: DOS Batch Forum
Topic: how to read filename from folder then output as variable?
Replies: 6
Views: 1612

how to read filename from folder then output as variable?

Hi all, I know there is a lot of this topic, but my case I can not put two steps as one. Basically I tried to search txt files end with *_debug_remove.txt then @echo off if exist foundfn.txt (del foundfn.txt) for %%F in ("C:\Users\abcd\*_debug_remove.txt") do echo %%~nxF>>foundfn.txt I used the abov...
by goodywp
10 Apr 2018 08:08
Forum: DOS Batch Forum
Topic: Is any way to compare these two txt files and get an message if the list on two are different, display the difference?
Replies: 8
Views: 3160

Re: Is any way to compare these two txt files and get an message if the list on two are different, display the differenc

Just a small adjustment in the code is needed: @echo off setlocal (set LF=^ %Empty line% ) (<nul cmd /V /C "for /F "skip=1 tokens=2" %%a in (text2.txt) do @set "m=%%a"&set /P "=!m:~0,6!!LF!"")|findstr /V /B /G:/ text1.txt Antonio Thanks Antonio! Yes it works! I added >>missinglist.txt at the end to...
by goodywp
10 Apr 2018 07:45
Forum: DOS Batch Forum
Topic: how to do this for the last line without comma?
Replies: 2
Views: 1031

Re: how to do this for the last line without comma?

You put the current line into a variable and don't write it out until the next line comes in. After the FOR command you write out the last line without the comma. set "line=" for /f "delims=" %%i in (debug_list.txt) do ( IF DEFINED line echo !line:~,8!,>>debug_extra.txt set "line=%%i" ) echo %line:...
by goodywp
09 Apr 2018 15:08
Forum: DOS Batch Forum
Topic: how to do this for the last line without comma?
Replies: 2
Views: 1031

how to do this for the last line without comma?

I have a task as below The code below shall give me all lines with comma, I added , after !line:~,8! for /f "delims=" %%i in (debug_list.txt) do ( set line=%%i echo !line:~,8!,>>debug_extra.txt ) the expected result is as below: 50001101, 50007201, 50013501, 50014301, 50013601, And the debug_list.tx...
by goodywp
09 Apr 2018 11:50
Forum: DOS Batch Forum
Topic: Is any way to compare these two txt files and get an message if the list on two are different, display the difference?
Replies: 8
Views: 3160

Re: Is any way to compare these two txt file and get an message if the list on two are different?

I tried this piece of code and give me the whole list of text1.txt not the two list which is not in the text2.txt It works here. text1.txt: 500006011000.S3S 500007011000.S3S 500008011000.S3S 500009011000.S3S 500010011000.S3S 500012011000.S3S 500014011000.S3S 500016011000.S3S 500134010100.S3S 500028...
by goodywp
09 Apr 2018 08:28
Forum: DOS Batch Forum
Topic: Is any way to compare these two txt files and get an message if the list on two are different, display the difference?
Replies: 8
Views: 3160

Re: Is any way to compare these two txt file and get an message if the list on two are different?

The phrase "compare two files and give the message that has different lists" doesn't makes sense in this case... We can show list elements in text1.txt that does not exist in text2.txt: @echo off setlocal (set LF=^ %Empty line% ) (<nul cmd /V /C "for /F %%a in (text2.txt) do @set "m=%%a"&set /P "=!...
by goodywp
09 Apr 2018 08:21
Forum: DOS Batch Forum
Topic: Is any way to compare these two txt files and get an message if the list on two are different, display the difference?
Replies: 8
Views: 3160

Re: Is any way to compare these two txt file and get an message if the list on two are different?

You could just use the FindStr command @Echo Off SetLocal EnableDelayedExpansion For /F "UseBackQ Delims=" %%A In ("text1.txt") Do (Set "_=%%A" FindStr /IC:"!_:~,6!" "text2.txt">Nul||Echo %%A) Pause Thank you! I tried and got the expected. Here are the expected results, just copied two piece of res...
by goodywp
06 Apr 2018 15:15
Forum: DOS Batch Forum
Topic: Is any way to compare these two txt files and get an message if the list on two are different, display the difference?
Replies: 8
Views: 3160

Is any way to compare these two txt files and get an message if the list on two are different, display the difference?

Hi I have two txt files and most time they are equal in terms of the list, but one just has some partial text1.txt is just a list as below 500006011000.S3S 500007011000.S3S 500008011000.S3S 500009011000.S3S 500010011000.S3S 500012011000.S3S 500014011000.S3S 500016011000.S3S 500134010100.S3S 50002801...
by goodywp
22 Mar 2018 08:15
Forum: DOS Batch Forum
Topic: How to separate long string with multiple quotations into multiple lines for each substring inside each quotation..
Replies: 8
Views: 2445

Re: How to separate long string with multiple quotations into multiple lines for each substring inside each quotation..

Thank you so much for all the input.... I would like to use @Echo Off For /F "UseBackQ Delims=" %%A In ("fdata1.txt") Do Call :EachLine %%A Exit /B :EachLine For %%A In (%*) Do (Set /P "=%%~A"<Nul&Echo=)>>"echo_data_1.txt" GoTo :EOF The reason I choose this one is that after processing, the ```` has...
by goodywp
21 Mar 2018 15:14
Forum: DOS Batch Forum
Topic: How to separate long string with multiple quotations into multiple lines for each substring inside each quotation..
Replies: 8
Views: 2445

Re: How to separate long string with multiple quotations into multiple lines for each substring inside each quotation..

I don't see why you would call to another function instead of just using echo to output the variables inside the FOR command. You will need to provide better examples of when it works and when it fails. We have no insight otherwise. You do need an exit or GOTO :EOF after your FOR and before your la...
by goodywp
21 Mar 2018 14:20
Forum: DOS Batch Forum
Topic: How to separate long string with multiple quotations into multiple lines for each substring inside each quotation..
Replies: 8
Views: 2445

How to separate long string with multiple quotations into multiple lines for each substring inside each quotation..

Hi all, I have an long string in a text file as below: "12345", "23456-1w3s", "abas-122", "9876-ads", "alfsajf;lda" Now my task is to separate it into multiple lines based on the quotation in an another text file as below: "12345" "23456-1w3s" "abas-122" "9876-ads" "alfsajf;lda" I tired as be low co...
by goodywp
19 Mar 2018 08:59
Forum: DOS Batch Forum
Topic: Is any way to insert blank lines in the text file?
Replies: 4
Views: 2020

Re: Is any way to insert blank lines in the text file?

Thank you both Compo and elzooilogico!!! it works perfectly!!! appreciated.
by goodywp
13 Mar 2018 16:09
Forum: DOS Batch Forum
Topic: Is any way to insert blank lines in the text file?
Replies: 4
Views: 2020

Re: Is any way to insert blank lines in the text file?

I did try the post suggested and not work as expected. And today I found that post has been withdrawn..
by goodywp
12 Mar 2018 15:00
Forum: DOS Batch Forum
Topic: Is any way to insert blank lines in the text file?
Replies: 4
Views: 2020

Is any way to insert blank lines in the text file?

Hi, I have a txt file and need to replace some txt for updating. ....... set oldgen=%oldgen: =% set newgen=%newgen: =% @echo off &setlocal set "search=%oldgen%" set "replace=%newgen%" set "textfile=Readme-how-to-use-this-package.txt" set "newfile=indesnew.txt" (for /f "delims=" %%i in (%textfile%) d...
by goodywp
12 Mar 2018 12:12
Forum: DOS Batch Forum
Topic: What is the best way to extract a substring within a longer string?
Replies: 2
Views: 1299

Re: What is the best way to extract a substring within a longer string?

Squashman wrote:
09 Mar 2018 16:05
FOR /F command and use the DELIMS option. Use the <> as the delimiters.
You were shown how to use the TOKENS and DELIMS options in this post.
Thank you and get what wanted:

Code: Select all

FOR /F "tokens=2,3 delims=<>" %%A IN (scheme_source.txt) DO @echo %%A>>scheme_target.txt