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

Jump to content


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

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

#121 User is offline   jaclaz 

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

Posted 27 August 2011 - 02:31 AM

View Posttomasz86, on 26 August 2011 - 05:56 PM, said:

I guess I'll have to stick to Update Inis as reordering the sections in this case doesn't have any influence on how update.inf works... and what's more important is that Update Inis seems to work smoothly.

You can still parse just the sections, before the "update" and then re-order the updated ini along those.
The original idea of splitting everything was exactly to have a way to keep the same section order.


jaclaz


#122 User is offline   tomasz86 

  • http://www.windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,220
  • Joined: 27-November 10
  • OS:Windows 2000 Professional
  • Country: Country Flag

Posted 17 October 2011 - 11:10 PM

jaclaz,

There is a problem with your script when system unicode code page is set to different languages, ex. if I set it to Korean and run your script I get this:

?kbid -> ?##쬴bid
&Send -> ?#쬢end
US & Canada -> US ?#?Canada
< -> ?###?
etc.


This post has been edited by tomasz86: 17 October 2011 - 11:11 PM


#123 User is offline   jaclaz 

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

Posted 18 October 2011 - 02:47 AM

View Posttomasz86, on 17 October 2011 - 11:10 PM, said:

jaclaz,

There is a problem with your script when system unicode code page is set to different languages, ex. if I set it to Korean and run your script I get this:



Well, you obviously need to review the half-@§§ed replacement strings I made for gsar to take care of this cases.
I have no idea what is "different" with those, but surely a "text" comparison doesn't help, do a hex one instead.

jaclaz

#124 User is offline   tomasz86 

  • http://www.windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,220
  • Joined: 27-November 10
  • OS:Windows 2000 Professional
  • Country: Country Flag

Posted 18 October 2011 - 03:13 AM

It'd have to be done for each language separately then :huh:

Isn't it possible to set a "fixed" codepage?

#125 User is offline   jaclaz 

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

Posted 18 October 2011 - 04:43 AM

View Posttomasz86, on 18 October 2011 - 03:13 AM, said:

It'd have to be done for each language separately then :huh:

Isn't it possible to set a "fixed" codepage?


I haven't yet understood (I fear because you completely failed to provide meaningful data to allow me to do so :ph34r:) what exactly the issue is.
I need:
  • the file BEFORE the runnning of the scripts
  • an EXACT description of the scripts you ran on it - or better a copy of the actual scripts you ran - and the order in which you ran them
  • the file AFTER the running of the scripts



Standard litany :whistle: :
http://homepages.tes...ard-litany.html

jaclaz

#126 User is offline   tomasz86 

  • http://www.windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,220
  • Joined: 27-November 10
  • OS:Windows 2000 Professional
  • Country: Country Flag

Posted 20 October 2011 - 01:18 AM

Well, after doing more tests I can say that it's not your script which is messing things up but yanklines.vbs script which I use to remove duplicates from files in SPLIT_* folder. When I have encoding for non-Unicode programs set to English or Polish, there are no problems but when I change to Korean it gets messed up.

Shall I still upload the files?

#127 User is offline   jaclaz 

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

Posted 20 October 2011 - 01:38 AM

View Posttomasz86, on 20 October 2011 - 01:18 AM, said:

Shall I still upload the files?

Well, not for me, unless it is a VERY OBVIOUS problem in the .vbs, it is UNlikely I can help you with it :ph34r: .
But I am pretty sure that someone will try and help you with it, so why don't you provide the files anyway

jaclaz

#128 User is offline   tomasz86 

  • http://www.windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,220
  • Joined: 27-November 10
  • OS:Windows 2000 Professional
  • Country: Country Flag

Posted 03 November 2011 - 09:48 AM

I've just switched back to Polish when using yanklines but I'll try to post these files later on.

However, I found two problems in splitinf.cmd

These type of lines

[Product.RunOnce]
;IE Installer
HKLM,"Software\Microsoft\Windows\CurrentVersion\RunOnceEx\101","002",,"%11%\mlang.dll|DllRegisterServer"
HKLM,"Software\Microsoft\Windows\CurrentVersion\RunOnceEx\101","004",,"%11%\browseui.dll|DllRegisterServer"
HKLM,"Software\Microsoft\Windows\CurrentVersion\RunOnceEx\101","005",,"%11%\browseui.dll|DllInstall|I"
HKLM,"Software\Microsoft\Windows\CurrentVersion\RunOnceEx\101","034",,"%11%\mshta.exe /register"


become

[Product.RunOnce]
;IE Installer
HKLM,"Software\Microsoft\Windows\CurrentVersion\RunOnceEx\101","034",,"%11%\mshta.exe /register"


after processing the file by splitinf.cmd. It's probably the "|" character to make them "disappear".

The other problem is that

[Strings]
START_PAGE           = "http://www.microsoft.com/isapi/redir.dll?prd=ie&pver=6&ar=msnhome"


becomes

[Strings]
START_PAGE = "http://www.microsoft.com/isapi/redir.dll?prd = ie&pver = 6&ar = msnhome"



#129 User is offline   tomasz86 

  • http://www.windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,220
  • Joined: 27-November 10
  • OS:Windows 2000 Professional
  • Country: Country Flag

Posted 22 November 2011 - 11:45 AM

I have one question. I use the following script to update *.cab files (fp40ext.cab in the example) from Win2k SP4

MD TEMP\fp40extcab
EXPAND -F:* %SP6%\fp40ext.cab TEMP\fp40extcab >NUL
FOR /F %%I IN ('DIR/B TEMP\fp40extcab') DO (
	IF EXIST HFMER\%%I (
		ECHO Processing %%I
		XCOPY/DY HFMER\%%I TEMP\fp40extcab\ >NUL
	)
)



I use XCOPY/DY to copy only files that are newer than the ones in the destination folder. I would be interested in having the "Processing %%I" displayed only when the actual file is copied and replaces the other one. Now it's displayed for all files regardless of whether they are actually copied or not (when they're older). Could it be done in a simple way?

#130 User is online   Yzöwl 

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

Posted 22 November 2011 - 12:50 PM

just a thought but why not get rid of the ECHO Processing %%I and remove the >NUL from the line below it!

Then again you may be able to remove the FOR loop entirely and simply run XCOPY with an additional /U switch!

#131 User is offline   jaclaz 

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

Posted 22 November 2011 - 01:02 PM

View Posttomasz86, on 22 November 2011 - 11:45 AM, said:

I use XCOPY/DY to copy only files that are newer than the ones in the destination folder. I would be interested in having the "Processing %%I" displayed only when the actual file is copied and replaces the other one. Now it's displayed for all files regardless of whether they are actually copied or not (when they're older). Could it be done in a simple way?

What about:

Quote

MD TEMP\fp40extcab
EXPAND -F:* %SP6%\fp40ext.cab TEMP\fp40extcab >NUL
FOR /F %%I IN ('DIR/B TEMP\fp40extcab') DO (
IF EXIST HFMER\%%I (
XCOPY/DL HFMER\%%I TEMP\fp40extcab\
XCOPY/DY HFMER\%%I TEMP\fp40extcab\ >NUL
)
)

Depending on the output you have in your language, you may want to use something like:

Quote

XCOPY/DL Source\%%I Target\ | FIND /V "0 File" | FIND /V "1 File"

(if a file is NOT copied, XCOPY will display (on my Italain System "0 File" and when a file is actually copied "1 File")

jaclaz

#132 User is offline   tomasz86 

  • http://www.windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,220
  • Joined: 27-November 10
  • OS:Windows 2000 Professional
  • Country: Country Flag

Posted 23 November 2011 - 05:13 AM

I like the XCOPY/U (XCOPY/DUY in this case) method for its simplicity ;)

I tested the other one suggested by jaclaz too (XCOPY/DL) but it asks whether to overwrite file or not. Also I'd prefer to have the script language neutral (I myself sometimes switch between different system locales).

There is just one more thing related to this part of the script:

MD TEMP\fp40extcab
EXPAND -F:* %SP6%\fp40ext.cab TEMP\fp40extcab >NUL
XCOPY/DUY HFMER\*.* TEMP\fp40extcab\



I need to repack the archive but It'd be nice to have it done only when there are new files copied. Before I used something like this:

FOR /F %%I IN ('DIR/B TEMP\fp40extcab') DO (
        IF EXIST HFMER\%%I (
                ECHO Processing %%I
                XCOPY/DY HFMER\%%I TEMP\fp40extcab\ >NUL
                IF NOT EXIST TEMP\fp40extcab\new MD TEMP\fp40extcab\new
        )
)
IF EXIST TEMP\fp40extcab\new (
	ECHO.&ECHO Repacking fp40ext.cab...
	CABARC N %SP6%\fp40ext.cab TEMP\fp40extcab\*.* >NUL
) ELSE (
	ECHO There are no new files to add.
)



Quite primitive but did the job more or less :ph34r: Now it's not applicable when the whole loop is replaced by XCOPY with the /U switch. Does anyone have any idea how such a checking could be done? Of course I can just always repack the archive even if there are no new files but it increases the time unnecessarily (especially when cabs such as driver.cab are processed...).

#133 User is offline   jaclaz 

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

Posted 23 November 2011 - 05:29 AM

View Posttomasz86, on 23 November 2011 - 05:13 AM, said:

I tested the other one suggested by jaclaz too (XCOPY/DL) but it asks whether to overwrite file or not.

Owww, comeon :whistle: , use XCOPY/DLY

jaclaz

#134 User is offline   tomasz86 

  • http://www.windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,220
  • Joined: 27-November 10
  • OS:Windows 2000 Professional
  • Country: Country Flag

Posted 23 November 2011 - 06:14 AM

View Postjaclaz, on 23 November 2011 - 05:29 AM, said:

Owww, comeon :whistle: , use XCOPY/DLY

Of course but then the only difference between the two is:

XCOPY/DY
1 Files(s) copied


vs.

XCOPY/DLY
1 File(s)


This post has been edited by tomasz86: 23 November 2011 - 06:14 AM


#135 User is offline   jaclaz 

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

Posted 23 November 2011 - 07:20 AM

View Posttomasz86, on 23 November 2011 - 06:14 AM, said:

View Postjaclaz, on 23 November 2011 - 05:29 AM, said:

Owww, comeon :whistle: , use XCOPY/DLY

Of course but then the only difference between the two is:

XCOPY/DY
1 Files(s) copied


vs.

XCOPY/DLY
1 File(s)



NO, the difference is that the L switch WON'T actually copy the file AND it will show the name of the file IF it corresponds to the D switch.

jaclaz

#136 User is offline   tomasz86 

  • http://www.windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,220
  • Joined: 27-November 10
  • OS:Windows 2000 Professional
  • Country: Country Flag

Posted 24 November 2011 - 12:03 AM

View Postjaclaz, on 23 November 2011 - 07:20 AM, said:

NO, the difference is that the L switch WON'T actually copy the file AND it will show the name of the file IF it corresponds to the D switch.

You're right (as always :ph34r:).

At the end I've just chosen the simplest method:

:: updating fp40ext.cab

ECHO.&ECHO.&ECHO Checking fp40ext.cab...&ECHO.
MD TEMP\fp40extcab
EXPAND -F:* %SP6%\fp40ext.cab TEMP\fp40extcab >NUL
IF EXIST HFMER\*.* XCOPY/DUY HFMER\*.* TEMP\fp40extcab\
XCOPY/DUY TEMP\i386\*.* TEMP\fp40extcab\
XCOPY/DUY TEMP\i386\new\*.* TEMP\fp40extcab\

ECHO.&ECHO Repacking fp40ext.cab...
CABARC N %SP6%\fp40ext.cab TEMP\fp40extcab\*.* >NUL
RD/Q/S TEMP\fp40extcab


It doesn't look very pretty but works nevertheless. The only downside is that the cab is repacked even if there are no new files copied.

This post has been edited by tomasz86: 24 November 2011 - 12:03 AM


#137 User is offline   jaclaz 

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

Posted 24 November 2011 - 03:57 AM

View Posttomasz86, on 24 November 2011 - 12:03 AM, said:

It doesn't look very pretty but works nevertheless. The only downside is that the cab is repacked even if there are no new files copied.


Hmmm.... :unsure:
What about something like:
SETLOCAL ENABLEDELAYEDEXPANSION
SET Counter=0
:: updating fp40ext.cab

ECHO.&ECHO.&ECHO Checking fp40ext.cab...&ECHO.
MD TEMP\fp40extcab
EXPAND -F:* %SP6%\fp40ext.cab TEMP\fp40extcab >NUL
IF EXIST HFMER\*.* FOR /F %%A IN ('XCOPY/DUY HFMER\*.* TEMP\fp40extcab\') DO SET Counter=!Counter!+1
FOR /F %%A IN ('XCOPY/DUY TEMP\i386\*.* TEMP\fp40extcab\') DO SET Counter=!Counter!+1
FOR /F %%A IN ('XCOPY/DUY TEMP\i386\new\*.* TEMP\fp40extcab\') DO SET Counter=!Counter!+1
ECHO %Counter% file(s) were added....
IF %Counter%.==0. ECHO You just unneededly wasted some processor cycles! &GOTO :Wherever
ECHO.&ECHO Repacking fp40ext.cab...
CABARC N %SP6%\fp40ext.cab TEMP\fp40extcab\*.* >NUL
 :Wherever
RD/Q/S TEMP\fp40extcab



:whistle:

jaclaz

#138 User is offline   tomasz86 

  • http://www.windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,220
  • Joined: 27-November 10
  • OS:Windows 2000 Professional
  • Country: Country Flag

Posted 24 November 2011 - 05:19 AM

It works but %Counter% is displayed as "+1+1+1+1+1+1+1+(and so on) file(s) were added".

#139 User is offline   jaclaz 

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

Posted 24 November 2011 - 07:25 AM

View Posttomasz86, on 24 November 2011 - 05:19 AM, said:

It works but %Counter% is displayed as "+1+1+1+1+1+1+1+(and so on) file(s) were added".


Change "SET Counter=!Counter!+1" to "SET /A Counter=!Counter!+1"

(just checking if you were paying attention ;) :whistle:)

jaclaz

This post has been edited by jaclaz: 24 November 2011 - 07:25 AM


#140 User is offline   tomasz86 

  • http://www.windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,220
  • Joined: 27-November 10
  • OS:Windows 2000 Professional
  • Country: Country Flag

Posted 24 November 2011 - 10:27 AM

This is the final version:

:: updating fp40ext.cab
SET Counter=0
ECHO.&ECHO.&ECHO Checking fp40ext.cab...&ECHO.
MD TEMP\fp40extcab
EXPAND -F:* %SP6%\fp40ext.cab TEMP\fp40extcab >NUL
IF EXIST HFMER\*.* FOR /F %%I IN ('XCOPY/DUY HFMER\*.* TEMP\fp40extcab\') DO SET /A Counter=!Counter!+1
FOR /F %%I IN ('XCOPY/DUY TEMP\i386\*.* TEMP\fp40extcab\') DO SET /A Counter=!Counter!+1
FOR /F %%I IN ('XCOPY/DUY TEMP\i386\new\*.* TEMP\fp40extcab\') DO SET /A Counter=!Counter!+1
ECHO %Counter% file(s) were added.
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
)
RD/Q/S TEMP\fp40extcab


The thing is that now file names are not displayed at all. I tried to use this:

IF EXIST HFMER\*.* FOR /F %%I IN ('XCOPY/DUY HFMER\*.* TEMP\fp40extcab\') (
     DO SET /A Counter=!Counter!+1
     ECHO Updating %%I
)


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

Share this topic:


  • 12 Pages +
  • « First
  • 5
  • 6
  • 7
  • 8
  • 9
  • 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