• 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

Thank you, ricktendo64. I'll check this tool for sure :)

I've got another problem - for some it's probably very simple but I can't get over it...

There is a directory which may be either empty or have some subdirectories inside.

I do

FOR /F %%I IN ('DIR/A-D/B DIRECTORY') DO (

and get "file not found" output when there are no files inside. Is there any way to prevent it from being displayed? Normally it's just

DIR/A-D/B DIRECTORY >NUL

but here I don't know where to put >NUL.

The other problem is that I wont to do

IF NOT EXIST DIRECTORY\*.* (

but subdirectories are also treated as *.*. Is there a simple way to check if there are no files (excluding subdirs) in a directory?

Edited by tomasz86
0

Share this post


Link to post
Share on other sites

I read these explanations and still don't know where I should put >NUL in this script:

	FOR /F %%I IN ('DIR/A-D/B HFMER') DO (
ECHO Copying %%I
MOVE HFMER\%%I %SP6%\sp6 >NUL
)

The "file not found" error is displayed when there are no files in HFMER.

Tell me the path+name the file I can give you some examples

The file path is %SP6UPD%\update.inf.

Edited by tomasz86
0

Share this post


Link to post
Share on other sites

I read these explanations and still don't know where I should put >NUL in this script:

You didn't read them "hard enough". :ph34r:

FORGET about your current project.

Create a new batch file with ONLY these commands, as CLEARLY stated on the given page:

http://www.robvanderwoude.com/battech_redirection.php

@ECHO OFF
ECHO This text goes to Standard Output
ECHO This text goes to Standard Error 1>&2
ECHO This text goes to the Console>CON

and test it as explained there.

Then try with:

@ECHO OFF
FOR /F %%I IN ('DIR/A-D/B HFMER') DO (
ECHO Copying %%I
ECHO No redirection:
MOVE HFMER\%%I %SP6%\sp6
ECHO.
ECHO Redirection of DEFAULT "Standard output" to NUL:
MOVE HFMER\%%I %SP6%\sp6 >NUL
ECHO.
ECHO EXPLICIT redirection of "Standard output" to NUL:
MOVE HFMER\%%I %SP6%\sp6 1>NUL
ECHO.
ECHO EXPLICIT redirection of "Standard Error" to NUL:
MOVE HFMER\%%I %SP6%\sp6 2>NUL
ECHO.
ECHO EXPLICIT redirection of BOTH "Standard output" "Standard Error" to NUL:
MOVE HFMER\%%I %SP6%\sp6 2>&1>NUL
)

jaclaz

0

Share this post


Link to post
Share on other sites

It still doesn't work... the problem is that I want to redirect this

('DIR/A-D/B HFMER')

to >NUL, not the rest which is after

DO (

The script stops after doing DIR if the directory is empty ("File Not Found").

Edited by tomasz86
0

Share this post


Link to post
Share on other sites

The script stops after doing DIR if the directory is empty ("File Not Found").

Well, the idea was to give you the hints, not doing your tests.... :whistle:

What happens with:

FOR /F %%I IN ('^>nul DIR/A-D/B HFMER 2^>^&1') DO (

jaclaz

0

Share this post


Link to post
Share on other sites

"^" was necessary :blushing:

Doing like this is enough for my script

FOR /F %%I IN ('DIR/A-D/B HFMER ^2^>NUL')

Thank you once again.

0

Share this post


Link to post
Share on other sites

Using COPY /B serves no purpose when used in that manner, in fact it is the default mode when copying single files.

I'm asking about this once again as I'd like to be sure.

If COPY/B has no use when copying single files, when do you actually have to use it?

Edited by tomasz86
0

Share this post


Link to post
Share on other sites

Basically, you should only require to use it when merging files into one.

Read more about it, (Notes: 3.).

0

Share this post


Link to post
Share on other sites

Basically, you should only require to use it when merging files into one.

Read more about it, (Notes: 3.).

Well, that seems to apply to MS-DOS 7.

The MS resource seen before:

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/copy.mspx?mfr=true

is about XP.

The one I cited seems like being NT4 and 2K "oriented":

http://ss64.com/nt/copy.html

(though as said it is possible that is alltogether "wrong", it does look similar to an actual output of a "COPY /?" ) :unsure:

Since it is not the first time that a "common" program syntax changes dramatically between one version of the OS and the other, it is still possible that NT4/2K behave differently.

I have found another "hits" for " /A : ASCII text file (default)":

http://www.bat-to-exe.com/batchcommands/copy.html

that seem like not coming from the same SS64 source.

@tomasz86

Why don't you simply try with a few files?

jaclaz

0

Share this post


Link to post
Share on other sites
Well, that seems to apply to MS-DOS 7.

The MS resource seen before:

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/copy.mspx?mfr=true

is about XP.

The one I cited seems like being NT4 and 2K "oriented":

http://ss64.com/nt/copy.html

(though as said it is possible that is alltogether "wrong", it does look similar to an actual output of a "COPY /?" ) :unsure:

Since it is not the first time that a "common" program syntax changes dramatically between one version of the OS and the other, it is still possible that NT4/2K behave differently.

I have found another "hits" for " /A : ASCII text file (default)":

http://www.bat-to-exe.com/batchcommands/copy.html

that seem like not coming from the same SS64 source.

@tomasz86

Why don't you simply try with a few files?

jaclaz

Summary from Windows XP and DOS 7 (above)

In Windows XP

/b is the default value for copy, unless copy combines files.

In Dos 7

By default:

When copying files from one location to another, COPY assumes binary mode;

When concatenating files, COPY assumes ASCII mode;

They dont appear to be contradictory so why would NT4 2000 have changed in between them
0

Share this post


Link to post
Share on other sites

They dont appear to be contradictory so why would NT4 2000 have changed in between them

It is a possibility, only trying to find a reason for the mentioned "/A (default)", BTW DOS 7 comes AFTER NT and before 2K.

jaclaz

0

Share this post


Link to post
Share on other sites

Typing error, NT5 2000

0

Share this post


Link to post
Share on other sites

I managed to get the UpdateInis working but is there any way to prevent moving the edited section to the end of the file?

I change some entries under [Version] and after that the whole [Version] section is moved to the end of the update.inf file.

0

Share this post


Link to post
Share on other sites

I managed to get the UpdateInis working but is there any way to prevent moving the edited section to the end of the file?

I change some entries under [Version] and after that the whole [Version] section is moved to the end of the update.inf file.

And again, no crystall ball available at the moment. :ph34r:

Standard litany:

http://homepages.tesco.net/J.deBoynePollard/FGA/problem-report-standard-litany.html

Additionally post the actual file that gives you problems (before and after the whatever steps you took into changing it).

jaclaz

0

Share this post


Link to post
Share on other sites

http://www.mediafire.com/file/1p82vz13vomc0g9/updateinis.7z

update-org - the original update.inf

updateinis.inf - the Update INIs file

update.inf - after running Update INIs (rundll32.exe advpack.dll,LaunchINFSection updateinis.inf,,1)

Are you talking of these?

[update.Version]

"D:\HFMER\SP\update.inf","Version","MaxNtServicePackVersion=1024","MaxNtServicePackVersion=1560"

"D:\HFMER\SP\update.inf","Version","ThisServicePackVersion=1024","ThisServicePackVersion=1560"

"D:\HFMER\SP\update.inf","Version",,"ThisServicePackBuild=1"

What if you use INSTEAD "Update .ini Fields sections (UpdateIniFields)":

http://technet.microsoft.com/en-us/library/dd346763.aspx

:unsure:

jaclaz

0

Share this post


Link to post
Share on other sites

I can't get it to work with UpdateIniFields. I've tried many different combinations but the best result I can get is:

UpdateIniFields


[DefaultInstall]
UpdateIniFields=Update.Version

[Update.Version]
"D:\HFMER\SP\update.inf","Version","MaxNtServicePackVersion","1024","1536"

Result


MaxNtServicePackVersion=MaxNtServicePackVersion= 1536

0

Share this post


Link to post
Share on other sites

I can't get it to work with UpdateIniFields. I've tried many different combinations but the best result I can get is:

You are right, it simply does not work :(, and anyway re-orders the sections as well.

jaclaz

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites

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.

Edited by tomasz86
0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites

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

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

0

Share this post


Link to post
Share on other sites

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.tesco.net/J.deBoynePollard/FGA/problem-report-standard-litany.html

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.