MSFN Forum: How to merge two text files? - MSFN Forum

Jump to content


  • 12 Pages +
  • « First
  • 6
  • 7
  • 8
  • 9
  • 10
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

How to merge two text files? and sort them... Rate Topic: -----

#141 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,369
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 24 November 2011 - 12:57 PM

What you'll could do is run XCOPY /DULY and STDOUT to a file. Then read that file as input looking for n File(s). If one or more files were indicated then create the temp folder, run the xcopy and repack.


#142 User is offline   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,574
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 24 November 2011 - 01:36 PM

View Posttomasz86, on 24 November 2011 - 10:27 AM, said:

but while displaying names of the updated files it also displays '0's (when no files are copied) and some other (?) numbers.

Yeah, life is tough. :(
Read again the lines with |FIND /V ....

This:
IF %Counter%.==0. ECHO.&ECHO There are no new files to add.
IF NOT %Counter%.==0. (
        ECHO.&ECHO Repacking fp40ext.cab...
        CABARC N %SP6%\fp40ext.cab TEMP\fp40extcab\*.* >NUL
)

makes no sense :ph34r: (what do you think that IF/ELSE exists for? :whistle: )

jaclaz

#143 User is offline   tomasz86 

  • http://windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,241
  • Joined: 27-November 10
  • OS:XP Pro x86
  • Country: Country Flag

Posted 24 November 2011 - 07:50 PM

Yzöwl said:

What you'll could do is run XCOPY /DULY and STDOUT to a file. Then read that file as input looking for n File(s). If one or more files were indicated then create the temp folder, run the xcopy and repack.

jaclaz said:

Yeah, life is tough. :(
Read again the lines with |FIND /V ....

But this would make the script system locale dependent which I would like to avoid ;)

#144 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,369
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 24 November 2011 - 11:11 PM

Well that would depend upon whether or not you thought for yourself or simply copied my statement exactly as I wrote it.

n is never going to be anything other than n in any language

Additionally, you cannot call something non language dependent which outputs English statements:

Quote

Checking
file(s) were added.
There are no new files to add.
Repacking


#145 User is offline   tomasz86 

  • http://windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,241
  • Joined: 27-November 10
  • OS:XP Pro x86
  • Country: Country Flag

Posted 25 November 2011 - 12:03 AM

That's why I wrote "system locale" independent, not language independent ;)

I'll try to use the temp folder method.

#146 User is offline   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,574
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 25 November 2011 - 03:35 AM

Don't use XCOPY.
Get STRARC:
http://www.ltr-data.se/opencode.html/
http://www.ltr-data....iles/strarc.txt
it's messages will be English allright AND you will have a "better" file copy utility.

jaclaz

#147 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,369
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 25 November 2011 - 11:20 AM

Are you trying to tell me that different system locales will output an integer differently, or is the wink and sarcasm about language included just to hide the fact that you hadn't looked at my advice and understood it. (you will note that I didn't provide you with code, that would have been in code tags, I gave you information you could use in order to solve the problem you were having, the exact pieces of code you needed were emboldened.)

Please also note that user locales would take precedence over system locales so technically you would want the script to be non user locale dependent.

#148 User is offline   tomasz86 

  • http://windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,241
  • Joined: 27-November 10
  • OS:XP Pro x86
  • Country: Country Flag

Posted 26 November 2011 - 12:48 AM

Where's your sense of humour, Yzöwl? :ph34r:

My comment about locales was related only to this part of your message and wasn't intended to be sarcastic at all.

Yzöwl said:

Additionally, you cannot call something non language dependent which outputs English statements:

Quote

Checking
file(s) were added.
There are no new files to add.
Repacking



I haven't got time yet to try the method you suggested and yes, I'm a beginner when it comes to batch scripting so I don't understand many of your script suggestions until I try to use them in practice. Please don't look for bad intentions everywhere!

#149 User is offline   tomasz86 

  • http://windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,241
  • Joined: 27-November 10
  • OS:XP Pro x86
  • Country: Country Flag

Posted 06 March 2012 - 05:08 AM

@jaclaz

I have a big problem with splitinf. When I use it on this inf file:

update.inf

some entries are not present in the final file (and in SPLIT_update folder too), ex. the [System32.Files] section comes out empty although it's not empty in the original update.inf.

BEAUTY_JOINED_update.inf

This post has been edited by tomasz86: 06 March 2012 - 05:15 AM


#150 User is offline   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,574
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 06 March 2012 - 05:48 AM

View Posttomasz86, on 06 March 2012 - 05:08 AM, said:

@jaclaz

I have a big problem with splitinf. When I use it on this inf file:

update.inf

some entries are not present in the final file (and in SPLIT_update folder too), ex. the [System32.Files] section comes out empty although it's not empty in the original update.inf.

BEAUTY_JOINED_update.inf

That's probably pretty much "normal".
That file has duplicate [System32.Files] entries, second one empty.
I seem to remember that entries need to be deduplicated first.

jaclaz

#151 User is offline   tomasz86 

  • http://windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,241
  • Joined: 27-November 10
  • OS:XP Pro x86
  • Country: Country Flag

Posted 06 March 2012 - 06:11 AM

double post :ph34r:

This post has been edited by tomasz86: 06 March 2012 - 06:12 AM


#152 User is offline   tomasz86 

  • http://windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,241
  • Joined: 27-November 10
  • OS:XP Pro x86
  • Country: Country Flag

Posted 06 March 2012 - 06:11 AM

Hmm, I'm not sure if that's the case. I've never experienced this problem before. In this case the first [System32.Files] seems to be ignored. I added "abc" to the second [System32.files] so now the two should be merged (as it's in case of other sections) but in the final file only "abc" is present under [System32.Files].

update.inf

BEAUTY_JOINED_update.inf

The script isn't case sensitive, is it?? It's [System32.files] vs [System32.Files] here.

@EDIT

It is case sensitive :} Is there any simple way to make it case insensitive?

@EDIT2

I'm just kind of guessing but maybe

IF /I "%%?"=="%Section%" SET dupe_Flag=1

instead of

IF "%%?"=="%Section%" SET dupe_Flag=1
?

This post has been edited by tomasz86: 06 March 2012 - 06:26 AM


#153 User is offline   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,574
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 06 March 2012 - 07:51 AM

View Posttomasz86, on 06 March 2012 - 06:11 AM, said:

I'm just kind of guessing but maybe

IF /I "%%?"=="%Section%" SET dupe_Flag=1

instead of

IF "%%?"=="%Section%" SET dupe_Flag=1
?

A very educated guess :thumbup
jaclaz

#154 User is offline   tomasz86 

  • http://windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,241
  • Joined: 27-November 10
  • OS:XP Pro x86
  • Country: Country Flag

Posted 28 March 2012 - 12:32 AM

By the way, I added these lines to splitinf.cmd and beautify.cmd:


1. splitinf.cmd

Before:
::Replace "==" with a dummy string "§#§"
CALL :run_gsar :x3d:x3d  :xa7:x23:xa7



After:
::Replace "==" with a dummy string "§#§"
CALL :run_gsar :x3d:x3d  :xa7:x23:xa7

::Replace even more stoopid ">=" with a dummy string "§#######§"
CALL :run_gsar :x3E:x3d  :xa7:x23:x23:x23:x23:x23:x23:x23:xa7

::Replace even more stoopid "<=" with a dummy string "§########§"
CALL :run_gsar :x3C:x3d  :xa7:x23:x23:x23:x23:x23:x23:x23:x23:xa7




2. beautify.cmd

Before:
::Replace dummy string "§#§" with "=="
CALL :run_gsar :xa7:x23:xa7 :x3d:x3d



After:
::Replace dummy string "§#§" with "=="
CALL :run_gsar :xa7:x23:xa7 :x3d:x3d

::Replace a dummy string "§#######§" with even more stoopid ">="
CALL :run_gsar :xa7:x23:x23:x23:x23:x23:x23:x23:xa7 :x3E:x3d

::Replace a dummy string "§########§" with even more stoopid "<="
CALL :run_gsar :xa7:x23:x23:x23:x23:x23:x23:x23:x23:xa7 :x3C:x3d



so now not only "==" but also ">=" & "<=" are processed correctly.

#155 User is offline   bphlpt 

  • MSFN Expert
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,116
  • Joined: 12-May 07

Posted 28 March 2012 - 01:33 AM

After all the work you've done with these various tools you've used and modified, would you please post all the current scripts/tools you use with a very brief description of how you use them, or are they all already conveniently available in one place?


Cheers and Regards

#156 User is offline   tomasz86 

  • http://windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,241
  • Joined: 27-November 10
  • OS:XP Pro x86
  • Country: Country Flag

Posted 28 March 2012 - 05:03 AM

No problem but I'd like to finish the script first. At this moment it still needs many fixes and addtions to be fully functional, especially concerning the SP part (merging updates works more or less). There are some issues with it too which I must fix before making it public, ex. the script now works in Windows 2000 only and doesn't in other versions of Windows, not even in XP.

#157 User is offline   tomasz86 

  • http://windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,241
  • Joined: 27-November 10
  • OS:XP Pro x86
  • Country: Country Flag

Posted 20 April 2012 - 04:34 AM

I added one more lines to splitinf.cmd:
::Replace even more stoopid "|" with a dummy string "§#########§"
CALL :run_gsar :x7c  :xa7:x23:x23:x23:x23:x23:x23:x23:x23:x23:xa7


and one to beautify.cmd:
::Replace a dummy string "§#########§" with even more stoopid "|" 
CALL :run_gsar :xa7:x23:x23:x23:x23:x23:x23:x23:x23:x23:xa7 :x7c


because some lines with "|" simply disappeared after running splitinf.cmd.

By the way, jaclaz, is there any particular reason to use the "§" character and not any other one? It gets "butchered" when system locale is set to some languages (Chinese, Korean, Japanese for sure) and therefore the final output is not correct.

This post has been edited by tomasz86: 20 April 2012 - 04:35 AM


#158 User is offline   tomasz86 

  • http://windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,241
  • Joined: 27-November 10
  • OS:XP Pro x86
  • Country: Country Flag

Posted 21 April 2012 - 06:40 AM

Has anyone got any idea how to process such lines automatically:

ELK_LOCALE_INUSE_201a=\
 "sth1"
ELK_MUI_INUSE_046e=\
 "sth2"

and get this:

ELK_LOCALE_INUSE_201a="sth1"
ELK_MUI_INUSE_046e="sth2"

? I've tried many different ways but can't get through it :/ I guess my commandline knowledge is too limited... There are different lines inbetween too.

This post has been edited by tomasz86: 21 April 2012 - 06:41 AM


#159 User is offline   allen2 

  • Not really Newbie
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,750
  • Joined: 13-January 06

Posted 21 April 2012 - 10:05 AM

This should do it (sed.exe is needed and is a port of gnu sed from the unix tools) :
type file| sed ":a;N;$!ba;s/=\\\n\ /=/g"


#160 User is offline   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,574
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 21 April 2012 - 01:00 PM

View Posttomasz86, on 20 April 2012 - 04:34 AM, said:

By the way, jaclaz, is there any particular reason to use the "§" character and not any other one? It gets "butchered" when system locale is set to some languages (Chinese, Korean, Japanese for sure) and therefore the final output is not correct.

You find another "rarely" used character and it will do.
I have it (the §) on my keyboard, so I tend to use it.
Though I cannot see how it can become "butchered", as it is simply an intermediate step, and it is "added" bu a batch and "removed" by the next. :unsure:
In any case the idea of §<n*#>§ is simply that of having an "unlikely to be present in a .inf/.ini/.sif" string for substitution, to reèplace characters that are not parsable by a batch.

The:

Quote

ELK_LOCALE_INUSE_201a=\
"sth1"

is most probably a =\CR+LF" sequence. If yes, you can use gsar allright.

jaclaz

Share this topic:


  • 12 Pages +
  • « First
  • 6
  • 7
  • 8
  • 9
  • 10
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy