Spoon2001 said:
I am wondering if there is a utility that makes it easier to use
command-line utilities. I know that when running a program like XXCOPY, a
command line can get pretty long.
The command-line is a very inflexible and unforgiving thing, when you are
typing the darned thing in.
<snip>
Let me give you my take on this issue. But, I can speak only for
XXCOPY.
If your command line gets very long, you need to prepare for possible
typing errors until you get it right. If you use Win9X, then, the
installation of DOSKEY is a MUST (in XP, it has a built-in command
line editor including the recall-previous-lines feature). But,
even the built-in text editor is so limited, you should use a text
editor such as NotePad.
Here's one possible scenario:
1. Open a DOS Box and make the current directory somewhere
convenient.
cd \windows
2. at the command line of the DOS Box, invoke Notepad
notepad runxx1.bat
If the "runxx1.bat" file does not exit, Notepad will display
a confirmation message box.
3. Inside Notepad, type your xxcopy command.
----------------------------------------------------------
xxcopy c:\windows\*.dll /S/LDTZ // list DLL files
----------------------------------------------------------
(Since this is a batch file, you may enter two or more
lines. Also, it is not limited to XXCOPY commands.)
After editing the line, make sure you save the newly edited
text by File > Save (or, type Ctrl-S).
4. Go back to the DOS Box (it's best you use both the
NotePad and DOS Box in the "Restore" mode (middle size
rather than full size windows so that both NotePad and
the DOS Box is side-by-side.
5. In the DOS Box, just run the batch file by typing the
batch file name to invoke it.
runxx1.bat
If you use %1, %2... inside the batch file, you can add
argument to the batch file.
If you make mistake, you can always re-edit the text inside
the NotePad window (and make sure you save it by Ctrl-S).
and run the batch file again.
I encourage you to make a useful batch file that can be used
later. If you do so, give a good name to remember. Then,
you should create a shortcut Icon in the desktop so that
in the future, you can just double click the icon.
Here's how.
1. Right-click at an empty area of the Desktop.
2. New > Short Cut and
3. type the batch file name (e.g., c:\windows\runxx1.bat )
4. Give whatever label to the Icon in the next step.
5. Click "Finish" and you will see an icon which is ready to
run the batch file you just edited.
6. (Assuming that you are in XP), inside the Icon's properties
sheet, you should adjust the DOS Box appearance such as
buffer dimension, size, font, color, etc.
==============
Let me show you a little more elaborate (but very useful)
technique using the XXCOPY command-file (/CF) feature.
1. Open a DOS Box.
2. Go to the convenient directory where you create XXCOPY
files. Here, I assume you go to c:\windows.
C:
cd \Windows
2. Run the next command to create an XXCOPY command file.
notepad MYBACKUP.XCF
Here, we are going to edit a file "MYBACKUP.XCF" (any file
name is fine --- I recommend the use of .XCF extension
which is XXCOPY's recommended command file name.
Now, this text file is intended to be run by the next
command:
xxcopy /CF:MYBACKUP.XCF
the /CF command accepts a filename which supplies the
command line text for the XXCOPY program command input.
The /CF (Command File) feature allows you to write
a very long command text (since XXCOPY may accept unlimited
number of exclusion items like /X:*.MP3 /X:c:\WINDOWS\ ...
it could become very long).
For a complete description of what's allowed in the command
file, see the following article:
http://www.xxcopy.com/xxcopy37.htm
In essence, the .XCF file is nothing but a regular text
file and the syntax is exactly the same as the XXCOPY
command line. That is, for a short command, the text
will look almost exactly like the batch file I talked
earlier except that the line does not start with XXCOPY.
3. After you finish editing the MYBACKUP.XCF file inside
NotePad, make sure that you save it (Ctrl-S) and then,
from the DOS Box (hopefully, you take my advise and you
now have a good looking, colorful DOS Box with your
favorite font). You are ready to run.
4. Run the XXCOPY command file directly by the following
command at the Dos Box.
xxcopy /cf:mybackup.xcf
In this case, this is not a batch file. You can run only
one job at a time.
5. Once you are happy with a good command file script, you may
again save it and set up an Icon for it on the Desktop.
In this case, the text for the shortcut is:
c:\windows\system32\xxcopy.exe /cf:mybackup.xcf /WE
Remember that this set up assumes that you have XXCOPY.EXE
in c:\windows\system32\ directory. Also, the command is
assumes that the "current directory" to run the command
is at c:\windows\ directory (where it can locate the
mybackup.xcf file). To set this condition for the icon,
you should right-click the icon and go to the properties
sheet and set the "Start in:" box with the intended
"current directory" (which will be c:\windows in this case).
(Note: the /WE switch guarantees that the XXCOPY screen remains
visible after it finishes the execution.)
A possible pitfall in doing this is where is the "current directory"
settings (Or, you can always spell out the fill path name for the
command file script (e.g., /CF:C:\mydir\mybackup.xcf).
Since the XXCOPY command file can use any number of lines,
you can spread the text more with lots of comments.
Here's a sample of an XXCOPY Command file (has a built-in
comments) ---- extracted from the XXTB #37 article.
script3.xcf
-----------------------------------------------------------
/*****************************************************
* *
* script3.xcf created 2002-05-05 *
* *
* This XXCOPY script carries out a daily *
* incremental backup operation from C: to E: *
* The E: drive may be made bootable as C:. *
* *
* Invocation: xxcopy /cf:c:\backup\script3.xcf *
* *
* Log file: c:\backup\script3.log *
* *
* Note: A command filename may have any extension. *
* We use .XCF (for Xxcopy Command File). *
* *
*****************************************************/
C:\ // source (the whole system disk)
E:\ // destination (mirror disk)
/clone // my favorite switch
/PZ0 // prompt killer (for /Z)
/ON:c:\backup\script3.log // create a log file
/Fo:c:\backup\script3.lst // save file list
/FM:dtzl // list file format control
// list of exclusions ------------------------------
/X:*.tmp // no temp files
/X:\Windows\*\cache*\ // cache files of any kind
/X:\*\cookies\ // cookies are junk food
/X:"c:\My documents\my pictures\2002-May// string split
\Susie's birthday\*.jpg" // into 2 lines
/*
A // sequence preceded by a non-blank character
allows you to logically connect two lines.
(This is a traditional C-like comment.)
*/
/EX:c:\backup\exclude.lst // you may use /EX inside
/CF:c:\backup\another.xcf // nestable (up to 8 levels)
:: An in-line comment may start by // or :: which ends
// at the end of the line.
-----------------------------------------------------------
==============
Anyway, anyone serious about using XXCOPY (or any command line
operation), you should always keep a few DOS Box open on the
desktop. I usually have three or four DOS Boxes at any given
time on my XP system. There is no reason to close them.
The fact that an application is a command-line program, there
is no reason for you to stay with the very limited command
line editor that comes with the DOS Box.
Kan Yabumoto
The Author of XXCopy