Date: Fri, 29 Aug 86 01:18:20 cdt From: Peter Wu Message-Id: <8608290618.AA00716@unix.macc.wisc.edu> To: info-ibmpc-request@mosis Subject: wmv12doc.txt MV - move/rename files or subdirectories for PC DOS 2.xx and 3.xx; version 1.20 SYNTAX MV [source1] [source2] ... [sourceN] [destination] Each [source] can specifies files or directories; wildcards are accepted. Typing MV without parameters will print a short help message, the version number, and the author's email addresses. OPTION Each [source] can be followed by a file-type option. There are three such options: /f - select files /d - select sub-directories (same effect as \.) /h - select hidden files/sub-directories /i - ask for confirmation to move for each file/sub-directory Options can be combined, like /hf for hidden and visible files. If neither /f or /d is specified, /fd (files and sub-directories) is used. If /h is not specified, hidden files/sub-directories are not moved. There should be no space between a source and its file-type option. So "*.*/f" is ok, but "*.* /f" is not. EXAMPLE Assume your directory looks like this: TROUT .CAT MOTHER . BILLARD .COM MOVIE .XXX COMPUTER.TXT LITTER . TRASHCAN DOS ANIMAL Each of the following examples are independent from the others: MV trout.cat cat.exe -- renames trout.cat to cat.exe MV litter trashcan -- moves litter into trashcan MV dos don'ts -- renames dos to don'ts MV *.* animal -- moves all five files, trashcan, and dos into animal. MV dos animal -- moves dos into animal MV billard.com computer.txt animal -- moves billard.com and computer.txt into animal MV trashcan trout.cat dos -- moves trashcan and trout.cat into dos MV *. trashcan -- moves mother, litter, dos, and animal into trashcan. Trashcan itself is not moved to prevent a directory loop. MV mother animal\. -- moves mother into animal. The "\." following animal says explicitly that animal is a sub- directory, and if mv doesn't find that directory, then you get an error message. This is a good way to move things into an existing sub-directory without accidentally renaming files if you mistype the destination name. MV mother litter -- error. You cannot rename mother to litter because litter exists already. If you really want to do this, you have to delete litter first. MV */d animal, or MV *\. animal -- moves trashcan and dos into animal. The "*/d" or "*\." says match all sub-directories with no extension. Animal itself is not moved to prevent a directory loop. MV *.*/f dos -- moves all files (trout.cat, mother, billard.com, computer.txt, and litter) into dos MV *.*/h animal -- moves all files and sub- directories, hidden and visible ones (trout.cat, mother, billard.com, movie.xxx, computer.txt, litter, trashcan, and dos), to animal MV *.*/hf animal -- moves all files, hidden and visible ones (trout.cat, mother, billard.com, movie.xxx, computer.txt, and litter), to animal MORE DETAIL MV is like the mv program on UNIX (trademark of AT&T Bell Labs.) It moves files/sub-directories within a physical disk. This is done by manipulating directory entries and not by copying and deleting files. The advantage is that it's fast and non- recursive: moving a sub-directory containing six hundred files takes the same amount of time as it takes to move an empty sub- directory. The disadvantage is that you cannot move files/sub-directories from one physical drive to another. To do so you must copy and then delete; MV doesn't help in this case. In addition to normal physical disks, MV also works on 1) 'Join'-ed disks; of course you still cannot move things across different physical disks. 2) 'Subst'-ed disks. The above 'disks' can be created in DOS 3.xx. MV will not work on shared disk across the network. If you attempt to use it this way, you will get the message 'sorry, mv doesn't work on network disks.' When MV is writing to the disk, it will ignore the break key. This is to prevent you from messing up the disk. If you press the break key while running MV, the program might not stop immediately, but it will eventually -- after it's done writing to the disk. However, you can still mess up your disk by rebooting or turning off your computer while running MV. So be careful: DO NOT STOP mv BY REBOOTING OR TURNING YOUR COMPUTER OFF; if you must stop MV, use the break key. WARNING Since MV uses some undocumented DOS calls and also writes disk sectors directly (three sectors per sub-directory moved), it is potentially hazardous to your disks. However, I have compensated for this by including some redundant checking in the program and by doing a lot of testing with it. MV has been tested on the following systems: 1) DOS 3.20 on AT with floppy disks (double and high density), fixed disks, vdisk, and 'subst' disk. 2) DOS 3.10 on Zenith 148, 158 with floppy disks (double density). 3) DOS 3.20 on XT with floppy disks (double density and 3.5") and fixed disk. 4) DOS 3.20 on PC convertible with 3.5" floppy disks. 5) DOS 2.11 on Leading Edge model D with floppy disks. 6) DOS 2.10 on PC with floppy disks. 7) DOS 2.11 on AT&T 6300 with floppy disks. 8) DOS 2.02 on Compaq with floppy disks. At first, I regularly ran chkdsk to make sure MV did not screw up the disks, but now I only run chkdsk occasionally because MV has never screwed up any disk, ever since I started writing it. If you have a system quite different from the above ones, test MV on a floppy disk before using it on fixed disks. And for the first few times you use MV, it's a good idea to run chkdsk right afterwards. You should also run chkdsk once BEFORE you try MV, to make sure you are starting with a 'clean' disk so you don't blame MV incorrectly for messing up your disks. I have tried my best to prevent you from getting internal error messages. But if you do see one, don't panic, your disk is probably not harmed, except when the message tells you to run chkdsk, then panic. Hopefully this will not happen -- it has never happened to me. BUGS Won't work on network disks. Won't work on "E-disk" under DOS 2.02 on Compaq. If you discover other bugs, please let me know. ALGORITHM Files move/rename are done with DOS function call 56H. Moving sub-directories (say MV A B/A) involves the following steps: 1) mkdir "B/A" 2) swap the starting cluster pointer of "A" and "B/A" 3) make "B/A"'s parent directory pointer point to "B" COMPILING A make file comes with the source. To compile the source, simply type "make mv". The sources are intended for the IBM C compiler version 1.0 or Microsoft C compiler version 3.0. If you use Microsoft C compiler version 4.0, you have to edit the front.c module to reverse the order of the parameters to the "rename" function. GUARANTEE This program comes with no guarantee. Standard disclaimer: use it at your own risks; neither I nor my employer is responsible for any consequence caused by the use of this program. Since the program comes with source, it is up to you to examine the source to determine whether you want to use the program or not. DISTRIBUTION Please distribute this program for free and include all unmodified source code. I will put the latest version of MV on the following bulletin boards (look for wmv??src.arc, wmv??exe.arc, and wmv??doc.txt. ?? is the version number): 1) INFO-IBMPC at MOSIS (for Arpanet users). Sources and document only. 2) CompuServe, in IBMSW's data library. 3) MACC's public BBS (608-262-3057) under IBMUTL. ACKNOWLEDGEMENT Many volunteers on Usenet have helped me tested MV on their systems. The following ones are especially helpful: Scott Rose Mr. Video David Dyck John P. Nelson AUTHOR Peter Wu Faculty Support Center, MACC Madison, WI 53706 Arpanet: pwu@unix.macc.wisc.edu Bitnet: WU at WISVMACC CompuServe: 76377,1332 UUCP: ..{akgua|seismo|harvard|ucbvax|allegra}!uwvax!uwmacc!pwu Suggestions, comments, and bug reports are welcome. I especially like to know other ways to move sub-directories and tests to prevent users from creating directory-loop.