home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
utility
/
pbaseiv.zip
/
P4DOS009.TIP
< prev
next >
Wrap
Text File
|
1991-12-16
|
2KB
|
78 lines
I often move files from one directory to another. Since I
don't want duplicate files cluttering my disk, I created a
batch file, MOVE.BAT [see listing], that copies and
deletes files with one command.
To avoid accidentally deleting important files, I built
safeguards into the batch file that ensure a safe and happy
move. Errors are reported if the destination file already
exists, if you mistype a file name, or if you specify a
nonexistent directory.
Bruce Purcell
Elk Grove, California
Editor's note: Copy MOVE.BAT to a directory in the current
PATH using the Alt-F command. Then type MOVE <file> <dir>,
where <file> is the pathname of the file to move and <dir>
is the destination. For example, MOVE NAMES.DAT C:\BACKUP
moves NAMES.DAT to C:\BACKUP and then deletes the original
file. If you attempt to move a file to a nonexistent
directory, MOVE.BAT will ask for confirmation before
creating the directory. MOVE.BAT has its limits; because it
looks for `%2\%1' when error checking, the batch file can't
move a file to the root directory.
I added a PAUSE command that lets you press <Ctrl>-C after
copying if you want to save the original file. If you don't
want this option, remove the first PAUSE and the three
preceding ECHO statements.
MOVE.BAT moves a file to a new directory, and then
optionally deletes the original file. (Extract using Alt-F)
---- BEGIN LISTING ----
@echo off
if not exist %1 goto NOFILE
if exist %2\%1 goto FILEERR
goto MOVEIT
:NOFILE
echo %1 not found. Check
echo your typing, then
goto ERREND
:FILEERR
echo %2\%1 already exists.
echo Delete duplicate and
goto ERREND
:MOVEIT
copy %1 %2 >nul
if not exist %2\%1 goto DIRERR
echo %1 moved to %2
echo Press Enter to delete
echo original file, or press
echo Ctrl-C and Y to quit.
pause
del %1
goto END
:DIRERR
echo N | del %2
echo Directory %2 not found.
echo Press Enter to create the
echo directory and move the file
echo or Ctrl-C and Y to quit.
pause
md %2
goto MOVEIT
:ERREND
echo try again.
:END
echo on
---- END LISTING ----
Title: Good Moves
Category: DOS
Issue date: May 1991
Editor: Tom Swan
Supplementary files: NONE