tomasz86

How to merge two text files?

238 posts in this topic

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.