listing differences.
in the sense of.
files in one and not the other.
directories in one and not the other
any ideas?
A single folder or including subdirectories?
What OS too?
I won't use the word folder here!
*directory*
!
> What OS too?
say, including subdirectories.
what DOS 6.22 solution would you suggest, and what NT solution would
you suggest?
>> >>I would like to compare 2 directories.
>>
>> >>listing differences.
>>
>> >>in the sense of.
>> >> files in one and not the other.
>> >> directories in one and not the other
>>
>say, including subdirectories.
>
>what DOS 6.22 solution would you suggest, and what NT solution would
>you suggest?
You either want it for NT or for DOS, if both then why?
> listing differences.
> any ideas?
*** I can't take the time right now to flesh out the operation, but DOS
users might consider employing the REPLACE command. Also XXCOPY has a wide
range of directory comparison switches.
The trick will be in getting one or the other to list the differences
instead of copying/replacing files. Both have listing features, but they
normally are for the copying or replacement operation not for difference
displays.
Richard Bonner
http://www.chebucto.ca/~ak621/DOS/
because I use both. But if you can only do one, then just pick one.
say, DOS. This is a DOS newsgroup after all.
I see ..
I am actually using NT at the moment, but I know that often there are
standard ways for a logical operation in one can be translated into
another. Such as applying an operation to a list of files... For
example, DOS's "bouncing off the command prompt" , and in NT, one can
also do FOR 'cos it takes a file.
I can see I could do xcopy /L and /U At DIR1, to get a list of files
that are in both. Then I could mark them all as +S/+H with attrib, so
xcopy doesn't see them. xcopy /L , still at DIR1, would give me files
in DIR1 and not DIR2.
And since attrib is an operation that applies to a list of filenames
by preceding it textually, Bouncing off the command prompt works..
note- no doubt as you suggest, xxcopy's /L features are more advanced
and I wouldn't need to mark any files with attrib.
But out of interest, regarding bouncing off the command prompt. I am
not sure if bouncing off the command prompt would work if text needed
to follow the filenames. What method would be used in such a case?
(not necessarily for this, but just generally, to do same kind of
function that bouncing off a command achieves, for without that
limited extra flexibility of only being able to proceed filenames)
>On Jul 24, 10:31 am, foxidrive <got...@woohoo.invalid> wrote:
>> On Thu, 24 Jul 2008 02:15:34 -0700 (PDT),jameshanley39
>>
>> <jameshanle...@yahoo.co.uk> wrote:
>> >> >>I would like to compare 2 directories.
>>
>> >> >>listing differences.
>>
>> >> >>in the sense of.
>> >> >> files in one and not the other.
>> >> >> directories in one and not the other
>>
>> >say, including subdirectories.
>>
>> >what DOS 6.22 solution would you suggest, and what NT solution would
>> >you suggest?
I used this in dos and Win98/XP for comparing directory trees -
I think the log can tell you what is missing as well.
CompTree v1.81 (C) Allan H¢iberg 1996-2002
Compares files (optionally including subdirectories) with each other:
CT <sourcespec> [<targetspec>] [<options>] [/?|/ERR?|/LOG?]
<Targetspec> will usually be the drive or directory containing the files you
want to compare the files in <sourcespec> with (a file will be compared with
other files of the same name only), but it can also be a single file.
Options;
/S : Include subdirectories in <sourcespec> in the source scan, and compare
files there to the files in identical <targetspec> subdirectories
/D : Delete source files & dirs that match. /DF: Only files. /DB: +Basedir
/N : No summary at end (default if single file specified)
/Q : Quick mode (assume that same size equals same contents). Q2: +Date/Time
/ON : Limit screen output (only console if specified, and help/command error)
/B : Beep when finished
/C : Console mode: Show results in bottom line. /C2: Show percentage
/? : Display this help screen. /B? : Display beep options
/ERR? : Display DOS errorlevels. /LOG? : Display logging options
Do a DIR on one directory into a file, append two DIRs of the other
directory to that file. Sort the file and pipe into DEDUPE, via sig
line 3, then redirect to file. You probably need DIR /b. You could use
my HUNT instead of DIR, to get the 8.3 names.
In that file, lines containing " 1" are from directory 1. lines
containing " 2" are from directory 2, lines containing " 3" are
from both.
For more directories, use 2^(N-1) copies of the N'th directory.
It will be limited by the SORT used, and there is an assumption that
file names do not contain multiple spaces followed by a necessary digit.
--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk DOS 3.3, 6.20; WinXP.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm> - also batprogs.htm.
> > jameshanley39(jameshanle...@yahoo.co.uk) wrote:
> > > I would like to compare 2 directories.
> > > listing differences.
> > > in the sense of.
> > > =A0files in one and not the other.
> > > =A0directories in one and not the other
> > > any ideas?
> >
> > *** =A0 I can't take the time right now to flesh out the operation, but D=
> OS
> > users might consider employing the REPLACE command. Also XXCOPY has a wid=
> e
> > range of directory comparison switches.
> >
> > =A0 =A0The trick will be in getting one or the other to list the differen=
> ces
> > instead of copying/replacing files. Both have listing features, but they
> > normally are for the copying or replacement operation not for difference
> > displays.
> >
> > =A0 =A0 =A0 =A0 =A0Richard Bonnerhttp://www.chebucto.ca/~ak621/DOS/
> I am actually using NT at the moment, but I know that often there are
> standard ways for a logical operation in one can be translated into
> another. Such as applying an operation to a list of files...
*** Yes, although the methods for NT versus DOS will often be different.
> For example, DOS's "bouncing off the command prompt" , and in NT, one
> can also do FOR 'cos it takes a file.
*** FOR is available in DOS, too. What do you mean by "bouncing off the
command prompt" ?
> I can see I could do xcopy /L and /U At DIR1, to get a list of files
> that are in both. Then I could mark them all as +S/+H with attrib, so
> xcopy doesn't see them. xcopy /L , still at DIR1, would give me files
> in DIR1 and not DIR2.
> And since attrib is an operation that applies to a list of filenames
> by preceding it textually, Bouncing off the command prompt works..
*** One can employ work-arounds in DOS, as many did in the early days
when DOS was much more limited. What you suggest may be able to be made to
work.
> note- no doubt as you suggest, xxcopy's /L features are more advanced
> and I wouldn't need to mark any files with attrib.
*** XXCOPY is very advanced. It has over 160(!) switches.
> But out of interest, regarding bouncing off the command prompt. I am
> not sure if bouncing off the command prompt would work if text needed
> to follow the filenames. What method would be used in such a case?
> (not necessarily for this, but just generally, to do same kind of
> function that bouncing off a command achieves, for without that
> limited extra flexibility of only being able to proceed filenames)
*** Since I don't understand your phrase "bouncing off the command
prompt", I can't answer that.
Richard Bonner
http://www.chebucto.ca/~ak621/DOS/
> CompTree v1.81 (C) Allan H█berg 1996-2002
> Compares files (optionally including subdirectories) with each other:
> CT <sourcespec> [<targetspec>] [<options>] [/?|/ERR?|/LOG?]
> <Targetspec> will usually be the drive or directory containing the files you
> want to compare the files in <sourcespec> with (a file will be compared with
> other files of the same name only), but it can also be a single file.
> Options;
(Snip CompTree Options)
> /D : Delete source files & dirs that match. /DF: Only files. /DB: +Basedir
*** Users should note the above. Empty directories will be deleted
unless one uses the `/DF' switch. That only allows deletion of files.
Richard Bonner
http://www.chebucto.ca/~ak621/DOS/
I guess it is because he really wants it to work in DOS
but if that isn't possible, in nt...
... wich leads me to to believe that he want it to work
without any third party programs?
Normally you would want some file manager program
with a good userinterface for that, something like totalcommanders
syncronise directories (but for dos), or norton commanders
compare directories (but nc didn't look in subdirectories I think,
but there are new opensource ones for dos you can use).
Easier to use that way, only reason to use a command line app
is if the 2 directories normally *should* be 100% equal all the
time and the commandlinecommand answers "yes they are equal"
or "BLEEP!! *Fatal Error* differences detected!!! :-("
In the case when there are normally files in one missing in the other,
then you would often like to copy the files to the other side
(and not doing it manually)
Back to the question... in dos with just builtin commands
you could do something like
dir /s /oe /a /a-d dir1 > dir1.txt
dir /s /oe /a /a-d dir2 > dir2.txt
fc dir1.txt dir2.txt
it should list all differences (too bad it allso lists the line
before and the line after the differing file tough)
But that just looks at filenames and date/size and don't
really compares the contents of the files so I wouldn't trust
it anyway....
(Perhaps this functionality in freedos "fc /s dir1 dir2"
would be something to add to the wishlist?)
ah.. when I spoke of applying an operating to a list of files, I
forgot.
FOR in DOS or NT can do it.
They can both do
for %f in (*.*) do asdfa %f asdf
But, to apply a command to a list of lines in a file. To process a
file and apply a command to each line. For that, FOR in DOS, and FOR
in NT, have an issue
How do you get around it?
An example of what I am getting at, is applying a command to all files
in a directory tree. Say, deleting *.txt in a directory tree.
One solution, for DOS, is Sweep and DEL. Sweep being a popular 3rd
party utility(made by pc magazine). Some DOS purists wouldn't use it.
c:\blah>sweep del *.txt
It would be nice to process a list of lines(e.g. filenames) from a
file, adding text before and after.
for %f in (file) do adfsf %f sdfsd
rather than being limited to something like
for %f in (*.xyz) do adfsf %f sdfsd
I am wondering, what method would you use?
I have heard of 4DOS, that that might do it. And I have seen text
replacement utlities mentioned, like minitrue, and the famous sed. I
am wondering how you solve such problems?
The following below is not as a question but merely FYI.
Below is an explanation of bouncing off the command prompt. I may have
it wrong, but it has been mentioned by legends in alt.msdos.batch ,
and perhaps here, in the past..
The purist solution, is "bouncing off the command prompt", a technique
I read in alt.msdos.batch , I saw it described in some posts by
william allen. I tried it some years ago. I may explain it wrong but
it is explained below..
(though as mentioned, I don't think it can append text to the end of a
line of a file).
here it is..
bouncing off the command prompt-
For example c:\blah>dir *.txt /s/b >thefile
Then you use a clever method to create a new file with something
prepended before it. Change the Prompt to display "DEL " (DEL
followed by space, ignore the quotes).
Then, rename thefile, to thefile.bat ,
If you then did c:\blah>type thefile.bat
You then get a list like
DEL a.txt
bad command or filename
DEL b.txt
bad command or filename
DEL c:\blah\sdf\av.txt
bad command or filename
So what you do, is
c:\blah>thefile >thefile2 <ENTER>
All the stderr (the stuff that goes out with the 2> stuff) stays on
the screen.
And all the > stuff, the DEL a.txt , DEL b.txt e.t.c. That goes to
your new file.
Rename thefile2 to thefile2.bat and execute it, and it does it.
However, I think that method won't let you put things -after- a line
of the original file.
For cases of dir /s/b. NT might remove some of the need for that
method, by having FOR /R, and some commands can scan through a tree
naturally, like ATTRIB. So remove some need.
4DOS might totally remove the need for this. (I heard it has an @file
option in FOR)
And it betters this method since FOR allows things to be written
before or after ie. before and after the %f that follows do.. (or in
4DOS's case, I suppose, before and after each line of a file)
e.g. regular DOS or NT.
echo. >a
for %f in (*.txt) do type "%f" >>a
HUNT, via sig line 3, will do that, using 8.3 file names, and selecting
files or directories by wildcarded name, size, date, attributes as
needed.
yes, I saw your solution.. I do plan to try it, I'm sure it works..and
i'm sure hunt has many other benefits.
and i'm sure foxidrive's solution works
and i am interested in richard's thoughts, what he would use..to go
through each line in a file.. and so on.
if people are willing to contribute solutions to a problem then that's
useful, and useful to everybody, not just me. And it gets archived
nicely.
and often one solution has applications or benefits that another
solution doesn't have.
> How do you get around it?
*** There are after-market softwares that can apply any DOS command to
any group of files, but I can't think of any of the names right now.
> An example of what I am getting at, is applying a command to all files
> in a directory tree. Say, deleting *.txt in a directory tree.
> One solution, for DOS, is Sweep and DEL. Sweep being a popular 3rd
> party utility(made by pc magazine). Some DOS purists wouldn't use it.
> c:\blah>sweep del *.txt
*** I use whatever does the job. The DR-DOS "DEL" command has a `/S'
switch, so:
DEL *.TXT /S
> It would be nice to process a list of lines(e.g. filenames) from a
> file, adding text before and after.
> for %f in (file) do adfsf %f sdfsd
> rather than being limited to something like
> for %f in (*.xyz) do adfsf %f sdfsd
> I am wondering, what method would you use?
*** To del from a list of files in DR-DOS I'd use:
XDEL @D:\path\filename.ext
> I have heard of 4DOS, that that might do it.
*** 4DOS can work with file lists.
> And I have seen text replacement utlities mentioned, like minitrue,
> and the famous sed. I am wondering how you solve such problems?
*** I use whatever utilities are necessary, If they can't do it
directly, I write a batch file using DOS and programs such as XSET,
XXCOPY, MiniTrue, Norton or PCTOOLS utilities, or other.
One or more links to websites
for the referred program(s)
can be found at:
http://www.chebucto.ca/~ak621/DOS/Websites.html
Richard Bonner
http://www.chebucto.ca/~ak621/DOS/
>yes, I saw your solution.. I do plan to try it, I'm sure it works..and
>i'm sure hunt has many other benefits.
>
>and i am interested in richard's thoughts, what he would use..to go
>through each line in a file.. and so on.
>
>if people are willing to contribute solutions to a problem then that's
>useful, and useful to everybody, not just me. And it gets archived
>nicely.
>
>and often one solution has applications or benefits that another
>solution doesn't have.
@echo off
if not "%1"=="" goto start
echo.
echo. Syntax: %0 listfile
echo.
echo. Purpose: This will perform an operation upon a list of files
echo or subdirectories etc that are contained in a text
echo. file with one item per line
echo.
echo. If no listfile is specified, it will merely list each
echo. subdirectory that is in the current directory.
echo.
echo. Note: Insert your desired operations between the
echo. ":: top" and the ":: bottom" statements below.
echo.
echo. Requirements: This batch uses FIND (msdos) and expects
echo. it to be on the path.
echo.
echo. NO LONG FILENAME OR DIRECTORY NAME SUPPORT
echo. but long items without spaces etc will work.
echo. Tested with Msdos V6.22 and Windows 98 SE
pause
dir /o:n /a:d /b >temp0.bat
:start
if not "%1"=="" if exist %1 copy %1 temp0.bat>nul
:: number the list
echo.>>temp0.bat
echo.>>temp0.bat
type temp0.bat|time|find /i "enter"|find /n /i "enter">temp0.bat
echo set target=%%6>enter.bat
echo set count=%%2>----------.bat
if exist temp1.bat del temp1.bat
:loop
:: counter
echo !>>temp1.bat
find /c "!" temp1.bat>temp2.bat
call temp2.bat
:: strip the item with the number of the counter
type temp0.bat|find "[%count%]Enter "|time|find "[%count%]">temp3.bat
call temp3.bat
:: check for final item
if "%target%"=="" goto end
:: top
echo Processing item number %count% - %target%
:: bottom
goto loop
:end
for %%a in (enter ----------) do if exist %%a.bat del %%a.bat
for %%a in (temp0 temp1 temp2 temp3) do if exist %%a.bat del %%a.bat
for %%a in (target count dir file) do set %%a=
problem is what if the directory has subdirectories, and I want to
compare those filename-paths too.
dir /s/b, doesn't give relative paths, it gives absolute paths.. So
it won't fulfill this purpose with dedupe.
In the command prompt output below.
there is the "a" subdirectory and the "b" subdirectory.
each has a directory called sdf, and file within it called z
I could simplify the output with dir /s/b/o-d , to remove directories
from the listing and just show the files /s, but doesn't matter.
The point i'm making is that the z file is in both subdirectories 'a'
and 'b' but the lines they produce is different, because the paths are
absolute.
So the solution you mention that uses dir and dedupe, won't work.
C:\DOCUME~1\name>dir /s/b a
C:\DOCUME~1\name\a\sdf
C:\DOCUME~1\name\a\sdf\z
C:\DOCUME~1\name>dir /s/b b
C:\DOCUME~1\name\b\sdf
C:\DOCUME~1\name\b\sdf\z
It would be fine if I didn't care about subdirectories.
And of course I could always go through the file and replace
\b\ with \a\ , so I could get it to work. e.g. doing the replace with
sed, or perhaps minitrue.
your idea is a clever one mathematically..
I figured it out without much time or trouble..
But i'll express the fruit of my understanding/findings here incase it
helps anybody get anywhere quicker.
I must say, it didn't take long.. what you wrote was very clear, and
the solution you gave was very simple.
I prob won't use it at the moment, but it's really good to know about,
I am interested (at the moment i'm on NT and an easy solution i'm
using at the moment is so third party it's really not much of a DOS
solution. cygwin and the diff command.)
Note to others, about the dir dedupe solution.. as an explanation.
if one wants to download dedupe, see
http://www.merlyn.demon.co.uk/
See "Batch in DOS..Win98/ME" under his "topic links"
takes you to
a page where you see
"A Programs directory, with indexes in text and HTML modes"
click that, you get
http://www.merlyn.demon.co.uk/programs/00index.htm
edit..find..dedupe
it mentions minitrue as being able to do this. (and no doubt minitrue
can do more)
He offers dedupe.exe and dedupe.pas and dedupe.zip that contains those
2.
When one runs dedupe, nothing is displayed.. So if one looks for clues
at dedupe.pas (the source code, which is in pascal)
there is a comment at the top , that says
"FILTER; just pipe a sorted list through DEDUPE"
It is as simple as that...
it takes a sorted list, e.g. in this one
the line containing the text "a" occurs 3 times. b twice, c 3 times, d
once. 9 lines
a
a
a
b
b
c
c
c
d
So it displays all the unique lines and how many times they occur.
C:\DOCUME~1\name>type file | sort | dedupe
3 a
2 b
3 c
1 d
4 lines out
So, if you have 2 directories each with files
DIR1(a,b)
DIR2(a,d,e,f)
and as john said, make a file that lists DIR1 once and DIR2 twice.
dir DIR1 /b >f
dir DIR2 /b >>f
dir DIR2 /b >>f
Any item that occurs once, is in DIR1 only.
Any item that occurs twice is in DIR2 only
Any item that occurs thrice is in both.
If you had just outputted DIR1 and then DIR2 ,
and a file occurred once, it could be DIR1 XOR DIR2. (i.e. one or the
other but not both). You wouldn't know which one though.
And if you have, say, 4 directories.
output DIR1 once
DIR2 twice
DIR3 4 times
DIR4 8 times.
so the pattern is the famous powers of 2.
4 directories 2^(n-1) as john said.
The reason for example DIR3 is 4 times, is because 3 times is for DIR1
AND DIR2. And the reason DIR4 is 8, is because infact all numbers
1-7 can be made by adding (1,2,4), which are all the combinations for
which directory/directories the file is in.
It looks like dedupe works beyond 8.3 too..
It's good to know about that solution..
thanks
. .
that assumption with dedupe, that the file doesn't contain multiple
spaces followed by a digit.. That is not ideal.. It's alright for
files I name but if I had saved website files and was comparing the
subdirectory of those too, one could run into some oddly named
filename , like with spaces followed by a digit.
for what i'm using it for it's fine..
your solution is excellent.. it does truly compare 2 files or even
more than 2.
The fact that when comparing 2 directories.. getting lists with dir /s/
b, gives absolute paths, and requires sed or something to e.g. make
the paths relative or the path leading up to the directories the
same.. That is not an issue with your solution.. it's an issue with
dir and comparing 2 files as I described. So it makes perfect
sense..using something like sed too. And although it's about 4
commands,
dir ... >a , dir ... >>a, dir ... >>a , sed ...
putting them in a batch file and using that is no problem.
Your solution is also quite generic.. comparing any 2 or more files.
Considering how useful that use of dedupe is..
I wonder
Are there any other uses of dedupe that come to mind?
Be interesting to know what purpose(s) you had in mind for it when you
wrote it. And if you found any "new" purposes for it.
>> It will be limited by the SORT used, and there is an assumption that
>> file names do not contain multiple spaces followed by a necessary digit.
Applies only if FIND is used to classify.
>dir /s/b, doesn't give relative paths, it gives absolute paths.. So
>it won't fulfill this purpose with dedupe.
so use my HUNT, with appropriate O & P5 options. However, it will give
only the Short Name.
>It looks like dedupe works beyond 8.3 too..
DEDUPE is a filter, and knows nothing of file names.
--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk DOS 3.3 6.20 ; WinXP.
>> It will be limited by the SORT used, and there is an assumption that
>> file names do not contain multiple spaces followed by a necessary digit.
>>
>> --
>
>that assumption with dedupe, that the file doesn't contain multiple
>spaces followed by a digit..
Limitation applies only if using DOS FIND, Windows FINDSTR searches can
be anchored to the start of the line.
--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05.
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
but your solution didn't involve "find". It involved dir | sort |
dedupe
Regarding HUNT..
a)it only supports 8.3 right?
b)I looked at it, so many options. There are alot of other more
standard things with many options that I don't know. A bigger
priority is studying xxcopy. It would be good if I can get to HUNT, it
looks very interesting and technical.. I do like that.
I know what dedupe does. And appreciate the application of using it
for comparing 2 directories. What other applications are there for
dedupe?
note- I didn't have findstr.exe on my win xp(sp2), I see that I was
meant to have it in win xp. according to http://www.computerhope.com/findstr.htm
But I got it with a google of intitle:index.of findstr.exe , and
emailed it to myself for posterity.
That was for separating out the one-place, other-place, both-places
lines, by pipeing into such as FIND " 2" ; I just left the means
implicit.
>Regarding HUNT..
>a)it only supports 8.3 right?
Yes. It was started about 20 years ago. I very rarely use names
greater than 8.3. And I have not-quite-extinct reasons for wanting to
keep the EXE small.
>b)I looked at it, so many options. There are alot of other more
>standard things with many options that I don't know. A bigger
>priority is studying xxcopy. It would be good if I can get to HUNT, it
>looks very interesting and technical.. I do like that.
Look also at COLS, same location.
>I know what dedupe does. And appreciate the application of using it
>for comparing 2 directories. What other applications are there for
>dedupe?
I cannot recall why I wrote it. But it can be used whenever a list
needs De-Duplicating.
--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk DOS 3.3 6.20 ; WinXP.