MSFN Forum: How to merge two text files? - MSFN Forum

Jump to content


  • 12 Pages +
  • « First
  • 4
  • 5
  • 6
  • 7
  • 8
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

How to merge two text files? and sort them... Rate Topic: -----

#101 User is offline   tomasz86 

  • http://www.windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,220
  • Joined: 27-November 10
  • OS:Windows 2000 Professional
  • Country: Country Flag

Posted 08 August 2011 - 10:56 AM

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?

This post has been edited by tomasz86: 08 August 2011 - 11:04 AM



#102 User is online   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,447
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 08 August 2011 - 12:29 PM

View Posttomasz86, on 08 August 2011 - 10:56 AM, said:

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 User is offline   tomasz86 

  • http://www.windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,220
  • Joined: 27-November 10
  • OS:Windows 2000 Professional
  • Country: Country Flag

Posted 09 August 2011 - 04:15 AM

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.


ricktendo64 said:

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

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

This post has been edited by tomasz86: 09 August 2011 - 04:19 AM


#104 User is online   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,447
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 09 August 2011 - 05:43 AM

View Posttomasz86, on 09 August 2011 - 04:15 AM, said:

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 User is offline   tomasz86 

  • http://www.windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,220
  • Joined: 27-November 10
  • OS:Windows 2000 Professional
  • Country: Country Flag

Posted 10 August 2011 - 12:42 AM

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

This post has been edited by tomasz86: 10 August 2011 - 12:44 AM


#106 User is online   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,447
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 10 August 2011 - 01:00 AM

View Posttomasz86, on 10 August 2011 - 12:42 AM, said:

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 User is offline   tomasz86 

  • http://www.windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,220
  • Joined: 27-November 10
  • OS:Windows 2000 Professional
  • Country: Country Flag

Posted 10 August 2011 - 01:22 AM

"^" 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.

#108 User is offline   tomasz86 

  • http://www.windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,220
  • Joined: 27-November 10
  • OS:Windows 2000 Professional
  • Country: Country Flag

Posted 13 August 2011 - 06:16 AM

View PostYzöwl, on 31 July 2011 - 10:55 AM, said:

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?

This post has been edited by tomasz86: 02 March 2013 - 09:11 PM


#109 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,364
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 13 August 2011 - 07:43 AM

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

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

#110 User is online   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,447
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 13 August 2011 - 09:06 AM

View PostYzöwl, on 13 August 2011 - 07:43 AM, said:

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 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,364
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 13 August 2011 - 10:21 AM

View Postjaclaz, on 13 August 2011 - 09:06 AM, said:

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)

Quote

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 User is online   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,447
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 13 August 2011 - 10:44 AM

View PostYzöwl, on 13 August 2011 - 10:21 AM, said:

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 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,364
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 13 August 2011 - 10:48 AM

Typing error, NT5 2000

#114 User is offline   tomasz86 

  • http://www.windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,220
  • Joined: 27-November 10
  • OS:Windows 2000 Professional
  • Country: Country Flag

Posted 23 August 2011 - 04:26 AM

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.

#115 User is online   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,447
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 23 August 2011 - 05:01 AM

View Posttomasz86, on 23 August 2011 - 04:26 AM, said:

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 User is offline   tomasz86 

  • http://www.windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,220
  • Joined: 27-November 10
  • OS:Windows 2000 Professional
  • Country: Country Flag

Posted 25 August 2011 - 06:14 AM

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)

This post has been edited by tomasz86: 25 August 2011 - 06:15 AM


#117 User is online   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,447
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 25 August 2011 - 09:03 AM

View Posttomasz86, on 25 August 2011 - 06:14 AM, said:

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)


Are you talking of these?

Quote

[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 User is offline   tomasz86 

  • http://www.windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,220
  • Joined: 27-November 10
  • OS:Windows 2000 Professional
  • Country: Country Flag

Posted 25 August 2011 - 12:09 PM

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



#119 User is online   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,447
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 26 August 2011 - 08:02 AM

View Posttomasz86, on 25 August 2011 - 12:09 PM, said:

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 User is offline   tomasz86 

  • http://www.windows2000.tk
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2,220
  • Joined: 27-November 10
  • OS:Windows 2000 Professional
  • Country: Country Flag

Posted 26 August 2011 - 05:56 PM

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.

Share this topic:


  • 12 Pages +
  • « First
  • 4
  • 5
  • 6
  • 7
  • 8
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy