• Announcements

    • xper

      MSFN Sponsorship and AdBlockers!   07/10/2016

      Dear members, MSFN is made available via subscriptions, donations and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, become a site sponsor and ads will be disabled automatically and by subscribing you get other sponsor benefits.
tomasz86

How to merge two text files?

238 posts in this topic

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?

0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites

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"

0

Share this post


Link to post
Share on other sites

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?

0

Share this post


Link to post
Share on other sites

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!

0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites

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...).

0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites

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
0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites

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
0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites

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
0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites
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 ;)

0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites

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

I'll try to use the temp folder method.

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

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!

0

Share this post


Link to post
Share on other sites

@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
0

Share this post


Link to post
Share on other sites

@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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.