Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

How to merge two text files?

- - - - -

  • Please log in to reply
237 replies to this topic

#126
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,520 posts
  • Joined 27-November 10
  • OS:XP Pro x86
  • Country: Country Flag
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?
Posted Image
Unofficial Service Pack 5.2 for MS Windows 2000 <- use this topic if you need help with UURollup, Update Rollup 2 and other unofficial packages


How to remove advertisement from MSFN

#127
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,567 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag

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
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,520 posts
  • Joined 27-November 10
  • OS:XP Pro x86
  • Country: Country Flag
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"

Posted Image
Unofficial Service Pack 5.2 for MS Windows 2000 <- use this topic if you need help with UURollup, Update Rollup 2 and other unofficial packages

#129
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,520 posts
  • Joined 27-November 10
  • OS:XP Pro x86
  • Country: Country Flag
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?
Posted Image
Unofficial Service Pack 5.2 for MS Windows 2000 <- use this topic if you need help with UURollup, Update Rollup 2 and other unofficial packages

#130
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,540 posts
  • Joined 13-October 04
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

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
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,567 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag

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:

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:

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
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,520 posts
  • Joined 27-November 10
  • OS:XP Pro x86
  • Country: Country Flag
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...).
Posted Image
Unofficial Service Pack 5.2 for MS Windows 2000 <- use this topic if you need help with UURollup, Update Rollup 2 and other unofficial packages

#133
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,567 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag

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
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,520 posts
  • Joined 27-November 10
  • OS:XP Pro x86
  • Country: Country Flag

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)

Edited by tomasz86, 23 November 2011 - 06:14 AM.

Posted Image
Unofficial Service Pack 5.2 for MS Windows 2000 <- use this topic if you need help with UURollup, Update Rollup 2 and other unofficial packages

#135
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,567 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag


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
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,520 posts
  • Joined 27-November 10
  • OS:XP Pro x86
  • Country: Country Flag

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.

Edited by tomasz86, 24 November 2011 - 12:03 AM.

Posted Image
Unofficial Service Pack 5.2 for MS Windows 2000 <- use this topic if you need help with UURollup, Update Rollup 2 and other unofficial packages

#137
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,567 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag

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
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,520 posts
  • Joined 27-November 10
  • OS:XP Pro x86
  • Country: Country Flag
It works but %Counter% is displayed as "+1+1+1+1+1+1+1+(and so on) file(s) were added".
Posted Image
Unofficial Service Pack 5.2 for MS Windows 2000 <- use this topic if you need help with UURollup, Update Rollup 2 and other unofficial packages

#139
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,567 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag

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

Edited by jaclaz, 24 November 2011 - 07:25 AM.


#140
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,520 posts
  • Joined 27-November 10
  • OS:XP Pro x86
  • Country: Country Flag
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.
Posted Image
Unofficial Service Pack 5.2 for MS Windows 2000 <- use this topic if you need help with UURollup, Update Rollup 2 and other unofficial packages

#141
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,540 posts
  • Joined 13-October 04
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

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
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,567 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag

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
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,520 posts
  • Joined 27-November 10
  • OS:XP Pro x86
  • Country: Country Flag

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.

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 ;)
Posted Image
Unofficial Service Pack 5.2 for MS Windows 2000 <- use this topic if you need help with UURollup, Update Rollup 2 and other unofficial packages

#144
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,540 posts
  • Joined 13-October 04
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

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:

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



#145
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,520 posts
  • Joined 27-November 10
  • OS:XP Pro x86
  • Country: Country Flag
That's why I wrote "system locale" independent, not language independent ;)

I'll try to use the temp folder method.
Posted Image
Unofficial Service Pack 5.2 for MS Windows 2000 <- use this topic if you need help with UURollup, Update Rollup 2 and other unofficial packages

#146
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,567 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag
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
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,540 posts
  • Joined 13-October 04
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

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
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,520 posts
  • Joined 27-November 10
  • OS:XP Pro x86
  • Country: Country Flag
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.

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

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!
Posted Image
Unofficial Service Pack 5.2 for MS Windows 2000 <- use this topic if you need help with UURollup, Update Rollup 2 and other unofficial packages

#149
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,520 posts
  • Joined 27-November 10
  • OS:XP Pro x86
  • Country: Country Flag
@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

Edited by tomasz86, 06 March 2012 - 05:15 AM.

Posted Image
Unofficial Service Pack 5.2 for MS Windows 2000 <- use this topic if you need help with UURollup, Update Rollup 2 and other unofficial packages

#150
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,567 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag

@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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users