[comp.sys.ibm.pc.misc] mv command

draper@buster.cps.msu.edu (Patrick J Draper) (05/04/91)

In article <1991May3.172301.20142@midway.uchicago.edu> ab2r@quads.uchicago.edu (Marshall Abrams) writes:
>In article <49@swatty.UUCP> root@mus.com (Superuser) writes:
>>Does anybody out there have a version of mv for dos that works reasonably 
>
>No, but a shell program called Q-DOS II will perform this function.
>(I like Q-DOS better than other shells because it doesn't have to read
>the whole directory list every time it boots--it keeps a directory map
>in a file.)  I admit that a lot of the time, I'd rather have a command
>line mv, though.
>
>		Marshall Abrams
>		ab2r@midway.uchicago.edu

I've written a program called move.exe that will move files anywhere on
a drive, or to another drive.

I'll give it away to anyone who wants it.


------------------------------------------------------------------------
Patrick Draper     "College is supposed to prepare you for the future,
cps.msu.edu               but all my future's behind me." 
draper@cps.msu.edu      -- My GrandPa, age 85, Fall 1990 graduate
                           of Western Michigan University 
------------------------------------------------------------------------

ressler@galileo.ifa.hawaii.edu (Mike "IR" Ressler) (05/04/91)

In article <49@swatty.UUCP> root@mus.com (Superuser) writes:
>Does anybody out there have a version of mv for dos that works reasonably 

Try using 4DOS. It's got a very nice version of mv (move) and even better, it
allows you to alias your commands so they do only what you want them to do
(you can set clobber/noclobber equivalents). I started using 4DOS a couple of
weeks ago (time to register it ...) and don't see how I lived without it for
so long. It will cost you $50 if you decide to use it but it's worth every
penny in my opinion.
--
  Mike Ressler - Infrared Photon Jockey     ressler@galileo.ifa.hawaii.edu

  If at first you don't succeed, get a bigger sledgehammer.

newsham@wiliki.eng.hawaii.edu (Timothy Newsham) (05/05/91)

Sometimes the most easiest and quickest solutions elude us.

A simple batch file can make a great mv command.  Just create a batch file
with the following lines:

--BEGIN MV.BAT--
@echo off
copy %1 %2
del %1
--ENDOF MV.BAT--

For you less sophisticated MS-DOS users who want a mv command, do the
following:

First, get into the directory with DOS in it.  Then do the following:

C>copy con mv.bat
@echo off                              <- type exactly this
copy %1 %2                             <- type exactly this
del %1                                 <- type exactly this
^Z                                     <- type F6 and RET, NOT ^Z
C>                                     <- MS-DOS will write to disk, you now
                                          have a mv command!

All wildcard and other MS-DOS filename and filepath conventions apply to
your new mv command.

EXAMPLE OF USE:

C>mv DUMMY.FIL ..                      <- moves DUMMY.FIL into next higher
                                          directory

POTENTIAL PROBLEMS WITH QUICK & DIRTY MV:

Since mv copies the file(s) you want mv'ed, you will need empty disk space
equal to the length of file(s) to be moved.  Of course, this used disk
space will be returned to you after execution of the mv since the old
copy of the file(s) are deleted after copied to the new directory.

Oh, by the way, this quick and dirty mv command is in the public domain,
although you can send donations to:

JUST KIDDING....

Enjoy.

raymond@math.berkeley.edu (Raymond Chen) (05/05/91)

In article <12856@uhccux.uhcc.Hawaii.Edu>, newsham@wiliki (Timothy Newsham) writes:
>--BEGIN MV.BAT--
>@echo off
>copy %1 %2
>del %1
>--ENDOF MV.BAT--
>
>POTENTIAL PROBLEMS WITH QUICK & DIRTY MV:

If you spell the second argument wrong, you will find that your source
file was deleted.

Example:

   mv importnt.fil c:\long\pathnaem

Assuming you meant to type c:\long\pathname, importnt.fil will be deleted
with no backup copy anywhere.

Moral of the story:  Beware of batch files that do no error checking.

sigma@picasso.ipl.rpi.edu (Kevin Martin) (05/05/91)

newsham@wiliki.eng.hawaii.edu (Timothy Newsham) writes:
>Sometimes the most easiest and quickest solutions elude us.
>A simple batch file can make a great mv command.  Just create a batch file
>with the following lines:
[etc]

This thread has gone on a while, hasn't it?  A few weeks ago I was telling
someone else exactly why this is NOT what we're looking for.

1) If the copy fails, you delete the original, no saving throw.
2) If the destination is on the same drive, you have to:
   a) wait for the copy to finish, fragmenting your drivespace
   b) hope that you have enough room for both copies during the copy

I could also point out what happens if you do a 'copy *.* e:\dir' and
e:\dir doesn't exist.  You get all the current directory's files appended
together into a file called e:\dir.  If you then delete the source files,
you're royally hosed.

What we want is a small, fast, compatible, and reliable program to handle
the various cases intelligently.  If the drives are different, copy if
there's enough space, then delete if succeeded.  If on same drive, rewrite
directories to just change the entries, not move any data.  Other nice
features could include an option to move subdirectories (prune & graft),
and an intelligent ability to "cache" directory modifications so things
would go faster in case you weren't using a disk cache.

I use something called 'REDirect' which someone renamed to 'mv.com'
somewhere along the line.  It works fine, but won't copy/delete when it has
to.  It also won't rename along the way.  It also doesn't cache dir writes
or allow prune & graft.

I'd write one, but I don't have access to enough versions of DOS and such
to be sure of the compatibility.  Who wants to run a 'mv' command which
might turn your FAT into oatmeal?

-- 
Kevin Martin
sigma@ipl.rpi.edu
"Can I kiss one of the bridesmaids instead?"

mwizard@eecs.cs.pdx.edu (Craig Nelson) (05/05/91)

Using batch files and copy is a nice way to implement a file move
but it lends to not only the need for disk space the size of the 
file being moved, it also tends to reap murder in the disk fragmentation
department.  I got the source for mv.exe if anyone wants the program. It
updates the FAT table directly, making for not only quick moves, but
non-fragmenting ones at that.  Cheers :)

BTW,  send mail,  lets not eat up bandwidth (whatever that is).

 []====================================================================[]
 || Craig R. Nelson                | CCSofD Software Inc.              ||
 || Programmer                     | Beaverton, OR, 97005              ||
 || mwizard@eecs.ee.pdx.edu        | (unlisted on the net)             ||

mas35638@uxa.cso.uiuc.edu (Mike) (05/05/91)

Does the COPY command exit with an errorlevel?  

Mike Stangel
m-stangel@uiuc.edu

valley@gsbsun.uchicago.edu (Doug Dougherty) (05/06/91)

mas35638@uxa.cso.uiuc.edu (Mike) writes:

>Does the COPY command exit with an errorlevel?  

No.  DOS (actually, COMMAND.COM) internal commands do not set errorlevel.
Many batch files depend on this fact.  (In fact, it would be impossible
to check errorlevel more than once, if the if cmd changed it)
--

	(Another fine mess brought to you by valley@gsbsun.uchicago.edu)

hls@rwthinf.UUCP (Hans-Ludwig Stahl) (05/07/91)

mas35638@uxa.cso.uiuc.edu (Mike) writes:
>Does the COPY command exit with an errorlevel?  
No.
	HLS

crs@lanl.gov (Charlie Sorsby) (05/09/91)

In article <1991May3.172301.20142@midway.uchicago.edu>, ab2r@quads.uchicago.edu (Marshall Abrams) writes:
> In article <49@swatty.UUCP> root@mus.com (Superuser) writes:
>> Does anybody out there have a version of mv for dos that works reasonably 
> 
> No, but a shell program called Q-DOS II will perform this function.
> (I like Q-DOS better than other shells because it doesn't have to read
> [...]

Have you looked at the file utilities provided by the "GNUis DOS
project?"  This batch of utilities (futil.something, as I recall)
includes dos versions of a variety of such utilities found on Unix
machines.

GNUish DOS project files are available via ftp from:

			bigbang.berkeley.edu
			vulcan.phyast.pit.edu
			wsmr-simtel20.army.mil

official GNU:

			prep.ai.mit.edu

I'm sorry, I don't recall the directory where found but, as I
recall it was fairly obvious.  Try looking in /pub for something
that suggests "gnudos."  In some cases, you will need to get the
documentation from the real GNU project on prep.

For those of you not familiar with Unix commands, unless otherwise
specified by you, the program assumes that you know what you are
doing and that you really want to do it.  It *won't* ask if you
really mean it, and, once done, it generally can't be undone.

Best,

Charlie Sorsby						"I'm the NRA!"
	crs@lanl.gov