Merge .txt files, check duplicates and sort

May 26, 2010 at 00:59:41
Specs: Windows XP, 2Ghz Intel Dual-Core, 1Gb RAM
Hello everyone. I have a file with each line formatted as:
"Project, Status",project start, start-up

Example: "Alasis, Complete",10:00,00:03

I would like the batch to
• add a list of new projects but with random project start(in hours) and random start-up(in minutes) if the data inside the quotes("Project, Status",) is not found in the text file.
• Sort the edited txt file and save the file.

An example:
I have the txt file WEEK.txt. Inside it i have:
"Alex, Pending",07:00,00:01
"Magg, Finished",11:23,00:02

I want to add a specific list containing:
"Alex, Pending",08:00,00:21
"Alesis, Finished",05:39,00:03

The expected result would be:
"Alex, Pending",07:00,00:01
"Alesis, Finished",05:39,00:03
"Magg, Finished",11:23,00:02

Basically if the project name and status is the same then leave the original instace.

I'm sorry I couldn't explain any better. Hoping that it is understandable and easy to read.
Thanks for your time and intent to help.

See More: Merge .txt files, check duplicates and sort

Report •

May 26, 2010 at 13:31:45
@echo off & setlocal
copy /y week.txt new.txt
for /f "tokens=*" %%a in (list) do call :xx %%a
sort new.txt
set /p =week.txt will now be overwritten with new data, ctrl-c aborts
sort new.txt > week.txt
goto :eof
find %1<week.txt >nul 2>&1
if errorlevel 1 >> new.txt echo %1,%2,%3

Report •

May 27, 2010 at 00:11:53
Hi nbrane. I tried the script but in the new.txt i'm getting the same data with multiple lines of:

Report •

May 27, 2010 at 03:49:43
sorry, my mistake, fix this line like this:
for /f "tokens=*" %%a in (list) do call :xx %%a

(I had it right and messed it up in the cut/paste crapola).
if it doesn't work this go-round, let me know.

Report •

Related Solutions

May 27, 2010 at 05:20:23
It works. After the batch overwrites the week.txt there is always a line starts with an ascii character (a holow square) placed before the quotes.
That line is always the first in my custom list.

Report •

May 27, 2010 at 12:17:20
that's an eof char. most likely (ctrl-Z, or ^Z, char.26)
I could not duplicate this problem. I even put the ctrl-z into
my "week.txt" and it copies over, but the SORT takes it out
of the datastream. See if that box is anywhere in your
inputfile (week.txt) or in you workfile (list or whatever you called it). I don't know how it's getting in there, and SORT
should take it out if its at the end of new.txt.

Report •

May 28, 2010 at 06:53:50
Hi nbrane. Sorry for my late response. I uploaded the batch and the two files week.txt and jkl.txt used with the script. These will create the eof char. Please take a look and thanks for all your help. I appreciated.

Report •

Ask Question