Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can I copy a directory from one drive to another drive

3 views
Skip to first unread message

Ib Okstrøm

unread,
May 22, 2001, 3:10:45 AM5/22/01
to
I need to make a bat program ther copy a directory whit sevel sub
directoryes from one drive to another.

Ib

Todd Vargo

unread,
May 22, 2001, 3:41:19 AM5/22/01
to

Ib Okstrøm wrote in message <3B0A10F5...@vestas.dk>...

>I need to make a bat program ther copy a directory whit sevel sub
>directoryes from one drive to another.
>
>Ib


Type XCOPY/? at DOS prompt.

Here's some quick reference material too.
http://users.cybercity.dk/~bse26236/batutil/help/XCOPY_S.HTM
http://www3.sympatico.ca/rhwatson/dos7/

Todd Vargo (body of message must contain my name to reply by email)


William Allen

unread,
May 22, 2001, 4:41:15 AM5/22/01
to
Ib Okstrøm wrote in message
> I need to make a bat program ther copy a directory whit sevel sub
> directoryes from one drive to another.

In general:

XCOPY C:\folder\*.* A:\FOLDER\*.* /s /y

will copy the entire folder structure from a base name of:
C:\folder
to a base name of
A:\FOLDER

XCOPY C:\folder\*.* A:\NEWNAME\*.* /s /y

will copy the entire folder structure from a base name of:
C:\folder
to a base name of
A:\NEWNAME

Use other drive letters as you wish, or UNC format over a
network (in Win9x versions, not checked for legacy versions)

The /s switch says copy the sub-folder hierarchy
below the base name. Use the /e switch to include empty
folders.

The /y switch says go ahead and overwrite any same-named
files on destination.

For details of further switches that may be relevant,
such as /d /a or /m (in a backup context), type:
xcopy /?

In the Win9x GUI, use
xcopy /? | more
since the enhanced features are too long for the screen,
and in this environment, /c /h may also be relevant switches.

The \*.* appended to folder names makes the script more
readable, avoids any confusion on what is intended, and prevents
xcopy having to ask whether the target is a file or folder. Shorter
kludges are possible, but both pointless and less clear.

===A note on why UPPERCASE is used in the examples above:

If working in a LFN environment, such as Win9x from the GUI,
always specify the target folder name in UPPERCASE if it
can fit an 8.3 format and you don't care about case differences.
If you fail to do this you'll create a hybrid name.

A hybrid name is a long file/folder name created
unnecessarily to preserve one or more lowercase letters
in what could otherwise be an 8.3 name. If you create a
hybrid name, you add 32 bytes of clutter to the folder
index. And the folder index is searched for every file
open call, so you make disk access inefficient.

Capitalising a hybrid name with a later rename _DOES_NOT_
return it to 8.3 index format as is trivially seen with a disk
editor, or less trivially by careful reasoning from watching the
index positions of later file changes in the folder index DIR listing.

If you create a hybrid-named structure, it _may_ persist even
if you try to correct it by deleting then recreating the structure
in uppercase.
The reliable fix is:
1) Rename the hybrid named structure by changing
one character in the name.
2) Then delete it.
3) Then recreate it properly in uppercase.

To avoid hybrids, uppercase is _only_ required for the
actual item being created _in_ the part of the command
line that creates it. After that, Windows9x is case
insensitive to subsequent writes to the item.

--
William Allen


ram

unread,
May 22, 2001, 9:44:06 AM5/22/01
to
W.Allen,
Your explanation to use UPPERCASE to avoid hybrid name, is interesting.
Can you please explain it with an example, how it occurs.
Thank you.
ram

William Allen

unread,
May 22, 2001, 3:35:15 PM5/22/01
to
ram wrote in message
...snip

> Your explanation to use UPPERCASE to avoid hybrid name, is
> interesting. Can you please explain it with an example, how it occurs.

This post applies only when working in Windows 9x GUI.

Definition - hybrid name:


A hybrid name is a long file/folder name created
unnecessarily to preserve one or more lowercase letters
in what could otherwise be an 8.3 name. If you create a
hybrid name, you add 32 bytes of clutter to the folder
index. And the folder index is searched for every file
open call, so you make disk access inefficient.

NOTE:
You should avoid creating hybrid names if you care about
efficient disk access.

The whole process is absolutely trivial to understand _if_ you
can use a disk editor to look at what is actually happening in
folder indexes.

If you can't, you need to reason it out from looking at how files are
listed by DIR. The point is that a default DIR listing just lists file
and/or folder names in the order that they happen to lie in the folder
index (which I call a "directory" in what follows to distinguish it from
the "folder" as a mere specific bundle of files). So by:
a) starting with a completely fresh folder you have just created,
b) and by creating and deleting some hybrids,
c) and by creating and deleting some true 8.3 files,
d) and doing it all in the correct sequence,
e) and by noting where they appear in the default listing,
you can see through to what is really happening in the low-level
folder index structure. To demo it for yourself you must create the
files, in a special order, in a freshly created folder, and make no
mistakes (or you have to start all over).

This demo script will do all that for you to demonstrate what a
hybrid is, and show that renaming it to uppercase is futile.
I've already posted the fix to remake a hybrid to an 8.3 name
properly. The reliable fix is:


1) Rename the hybrid named structure by changing
one character in the name.
2) Then delete it.
3) Then recreate it properly in uppercase.

If you understand this concept, you'll see why (particularly in batch
scripts where you type the script once and use it many times) you
should always AVOID creating hybrid names by using UPPERCASE
for any 8.3 file or folder name _in_the_command_ that creates it. Once an
8.3 name is created properly, subsequent reference can be lowercase,
since Windows 9x is case-insensitive to existing file/folder access.

If using a full filespec, such as
C:\PathToFolder\FILENAME.EXT
where C:\PathToFolder is some folder structure that _already_ exists,
then ONLY the newly created file name need be in uppercase to avoid
a hybrid. This applies regardless of whether C:\PathToFolder happens
to be a short or a long name.

The demo script is quite long, but cut and paste it, run it and read
the explanations carefully.

::====HYBRID.BAT
@ECHO OFF
IF (%1)==(GOTO:) %1%2 SUBCALL (Subroutine handler)
:: Hybrid name demo - William Allen 22 May 2001
SET | find "windir=">NUL
IF ERRORLEVEL 1 GOTO USAGE

SET FN=C:\HYBRID
IF NOT (%1)==() SET FN=C:\%1
IF EXIST %FN%\NUL GOTO USAGE
MD %FN%
IF NOT EXIST %FN%\NUL GOTO USAGE

SET HFN=hybrid.ext
SET STA=NO

:REPEAT
CLS
ECHO. The folder %FN% has been freshly created, and is empty
IF %STA%==YES GOTO SKIPFTA1
ECHO. In what follows the term "directory" refers to the file
ECHO. holding the disk folder-index, consisting of at least one
ECHO. 32-byte entry for each file or subfolder in the folder.
ECHO. All DIR listings are in the default order, which lists
ECHO. files or folders in the order that they happen to lie
ECHO. in the folder-index. In what follows, it will help if
ECHO. you read the explanations slowly, so that as the demo
ECHO. creates files, they will have noticeably later times.
ECHO. This will show that the time of creation DOES NOT decide
ECHO. the default listing position in the folder-index.
:SKIPFTA1
CALL %0 GOTO: _HYBRID

ECHO.Hybrid-named file>%FN%\hybrid.ext
ECHO. The file %HFN% has now been created in %FN%.
IF %STA%==YES GOTO SKIPFTA2
ECHO. This file has a hybrid name and uses 2 directory entries
ECHO. (but it could be an 8.3 using only one entry if it had
ECHO. been created properly with UPPERCASE).
:SKIPFTA2
CALL %0 GOTO: _HYBRID

ECHO.8.3-named file>%FN%\FILE8-3.EXT
ECHO. The file FILE8-3.EXT has now been added to %FN%
ECHO. This is an 8.3-named file using 1 directory entry
ECHO. and is now the second file entry in directory %FN%
CALL %0 GOTO: _HYBRID

IF %STA%==NO GOTO SKIPFTA3
REN %FN%\hybrid.ext HYBRID.EXT
ECHO. This time around, we rename %HFN% to its uppercase
SET HFN=HYBRID.EXT
ECHO. equivalent, %HFN% but because it's a hybrid name, it
ECHO. still occupies 2 entries even though it looks like an
ECHO. 8.3 name. So the rest of the demo will still show it
ECHO. takes up two 32-byte entries
CALL %0 GOTO: _HYBRID

ECHO.8.3-named file>%FN%\2NDTIME.EXT
ECHO. We add another 8.3-named file, 2NDTIME.EXT and this file
ECHO. goes last showing that renaming %HFN% didn't free up any
ECHO. folder index entries.
CALL %0 GOTO: _HYBRID

:SKIPFTA3
DEL %FN%\hybrid.ext
ECHO. The file %HFN% has now been deleted from %FN%
ECHO. The first two entries in the directory are unoccupied
ECHO. Two 8.3-named files could go before FILE8-3.EXT
CALL %0 GOTO: _HYBRID

ECHO.8.3-named file>%FN%\FIRST.EXT
ECHO.8.3-named file>%FN%\SECOND.EXT
ECHO. Now we create two 8.3-named files FIRST.EXT SECOND.EXT
ECHO. Notice that both FIRST.EXT and SECOND.EXT appear
ECHO. before FILE8-3.EXT in a default folder listing because
ECHO. they were entered in the two positions freed by deleting
ECHO. the hybrid-named file %HFN%
IF %STA%==YES ECHO. (We won't repeat the rest of the Demo this time)
CALL %0 GOTO: _HYBRID

IF %STA%==YES GOTO SKIPREST

ECHO.8.3-named file>%FN%\THIRD.EXT
ECHO. Now we add a third 8.3-named file THIRD.EXT. Notice
ECHO. that its default listing position is after the other
ECHO. files because they now fill all the initial index
ECHO. positions in the directory.
CALL %0 GOTO: _HYBRID

DEL %FN%\FIRST.EXT
ECHO. Now FIRST.EXT has been deleted. That leaves 1 free index
ECHO. entry in the initial position of the directory. If
ECHO. we create a hybrid-named file (or any long-named file)
ECHO. it won't fit there, and will be listed last by default
CALL %0 GOTO: _HYBRID

ECHO.Hybrid-named file 2>%FN%\hybrid2.ext
ECHO. Now we have created hybrid2.ext and it's listed last
ECHO. because it requires 2 entries, so can't fit in the first
ECHO. position. The first position in the directory is still
ECHO. free. If we add an 8.3-named file, it will fit there.
CALL %0 GOTO: _HYBRID

ECHO.8.3-named file>%FN%\FOUR.EXT
ECHO. We now create FOUR.EXT, another 8.3-named file. Notice
ECHO. that FOUR.EXT goes first, because its index entry requires
ECHO. only 1 32-byte field (as does any true 8.3 name)
CALL %0 GOTO: _HYBRID

:SKIPREST
DEL %FN%\*.EXT
RD %FN%
IF %STA%==YES GOTO FINISHED
ECHO. Now press RETURN to repeat the demo, but on the second
ECHO. run through, we'll rename the file %HFN% to the
ECHO. uppercase version of its name after creating it. It
ECHO. still behaves as a hybrid-named file (because it is).
PAUSE>NUL
MD %FN%
SET STA=YES
GOTO REPEAT

:FINISHED
CLS
ECHO. That completes the simple demo.
ECHO.
SET FN=
SET STA=
SET HFN=

GOTO EOF
:USAGE (Instructions and error handler)
ECHO. Usage: %0 FolderName
ECHO. ===This Demo is for Windows 9x GUI only===
ECHO. FolderName should be the name of a folder that
ECHO. doesn't currently exist in the root folder of C:
ECHO. Don't include drive letter or \ in the foldername
ECHO. If you don't specify a foldername, C:\HYBRID is
ECHO. used as the default if it doesn't currently exist

GOTO EOF (=Subroutine code follows=)
:_HYBRID (Usage: CALL %0 GOTO: _SRNAME parameters)
ECHO.
DIR %FN%
ECHO.
ECHO. Press RETURN to continue
PAUSE>NUL
CLS

GOTO EOF
:SUBCALL (Subroutine error handler)
ECHO Missing/invalid parameter in: %0 %1%2 %3 %4
:EOF (End of file)
::====

--
William Allen


ram

unread,
May 22, 2001, 5:18:25 PM5/22/01
to
Thanks, for good education.
ram

ram

unread,
May 23, 2001, 12:30:16 PM5/23/01
to
W.Allen,
If I need to verify File/Folder index by diskeditor, how do I do that ?
I use Norton's DiskEdit.exe. Where (sector:offset) and what should I
look for ?
Thanks.
ram

William Allen

unread,
May 23, 2001, 2:01:25 PM5/23/01
to
ram wrote in message

> If I need to verify File/Folder index by diskeditor, how do I do that ?
> I use Norton's DiskEdit.exe. Where (sector:offset) and what should I
> look for ?

Open DiskEdit on, for example, drive C:
It should open by default in "Directory" view
of root folder.

Move cursor highlight to sub-folder you're
interested in and press [Return], or simply
click on foldername.

Press F2 to toggle to Hex view, press F4 to
toggle to folder-index "Directory" view.

You don't need to track sector:offsets with DiskEdit,
it tracks the sequence automatically for you and displays
sector:offset of whatever you're looking at.

If it doesn't open in correct view, try [Alt+[R]] and to
select a folder object.

If it still doesn't open in anything but Hex, you probably
have an old DiskEdit that can't read a FAT32 structure.

Press F1 for help. You can use DiskEdit in the Windows
GUI; it automatically goes into read-only mode in a DVM.

--
William Allen

PS
By the way, when you answer posts, be aggressive in
snipping out unnecessary stuff echoed from the post you're
responding to. No one will mind. And it makes it easier for
the next respondent if they don't have to scroll through
lots of stuff to make sure there are no more pieces to reply to.


0 new messages