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

#101
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,510 posts
  • OS:XP Pro x86
  • Country: Country Flag
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, 08 August 2011 - 11:04 AM.

post-47483-1123010975.png
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

#102
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,023 posts
  • OS:none specified
  • Country: Country Flag

Is there any way to prevent it from being displayed? Normally it's just

Learn about "Standard Output" and "Standard Error" and their redirection:
http://www.robvander...redirection.php
(already given to you)
AND:
http://www.robvander...redirection.php

jaclaz

#103
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,510 posts
  • OS:XP Pro x86
  • Country: Country Flag
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, 09 August 2011 - 04:19 AM.

post-47483-1123010975.png
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

#104
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,023 posts
  • OS:none specified
  • Country: Country Flag

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

#105
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,510 posts
  • OS:XP Pro x86
  • Country: Country Flag
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, 10 August 2011 - 12:44 AM.

post-47483-1123010975.png
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

#106
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,023 posts
  • OS:none specified
  • Country: Country Flag

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

#107
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,510 posts
  • OS:XP Pro x86
  • Country: Country Flag
"^" 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.
post-47483-1123010975.png
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

#108
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,510 posts
  • OS:XP Pro x86
  • Country: Country Flag

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, 02 March 2013 - 09:11 PM.

post-47483-1123010975.png
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

#109
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,530 posts
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

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

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

#110
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,023 posts
  • OS:none specified
  • Country: Country Flag

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...y.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-ex...mands/copy.html
that seem like not coming from the same SS64 source.

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

jaclaz

#111
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,530 posts
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

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

The MS resource seen before:
http://www.microsoft...y.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-ex...mands/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

#112
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,023 posts
  • OS:none specified
  • Country: Country Flag

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

#113
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,530 posts
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

Typing error, NT5 2000

#114
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,510 posts
  • OS:XP Pro x86
  • Country: Country Flag
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.
post-47483-1123010975.png
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

#115
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,023 posts
  • OS:none specified
  • Country: Country Flag

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.tes...ard-litany.html

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

jaclaz

#116
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,510 posts
  • OS:XP Pro x86
  • Country: Country Flag
http://www.mediafire...9/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)

Edited by tomasz86, 25 August 2011 - 06:15 AM.

post-47483-1123010975.png
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

#117
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,023 posts
  • OS:none specified
  • Country: Country Flag

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.micro...y/dd346763.aspx

:unsure:

jaclaz

#118
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,510 posts
  • OS:XP Pro x86
  • Country: Country Flag
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

post-47483-1123010975.png
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

#119
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,023 posts
  • OS:none specified
  • Country: Country Flag

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

#120
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,510 posts
  • OS:XP Pro x86
  • Country: Country Flag
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.
post-47483-1123010975.png
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

#121
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,023 posts
  • OS:none specified
  • Country: Country Flag

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
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,510 posts
  • OS:XP Pro x86
  • Country: Country Flag
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, 17 October 2011 - 11:11 PM.

post-47483-1123010975.png
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

#123
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,023 posts
  • OS:none specified
  • Country: Country Flag

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
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,510 posts
  • OS:XP Pro x86
  • Country: Country Flag
It'd have to be done for each language separately then :huh:

Isn't it possible to set a "fixed" codepage?
post-47483-1123010975.png
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

#125
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,023 posts
  • OS:none specified
  • Country: Country Flag

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN