DO v. 2.09 (19/5/2020, Martin Vieregg) |
Readme/What's new |
DO 2.00 for OS/2 Martin Vieregg, Germany
Freeware martin at hypermake.de
May 2020
Homepage:
http://www.hypermake.com
DO 2.09
commandline/terminal program with a set of functions
DO is a set of very useful batch enhancements and command line utilities.
This version replaces a handful of old freeware exe programs which stopped
running properly due to integer overflow. DO.EXE also works if the results
are larger than 32 bits, e.g. free disk space larger than 4 GB. If you would
like to see any functions added, please send me your suggestions.
DO is available for Win32, OS/2, Linux and Mac.
The syntax of the documentation is orientated to Windows and OS/2 (backslash,
drives).
----------- Installation ---------
On Windows and OS/2, copy DO.EXE into a directory of your PATH statement.
If you use other third-party commandline windows, your environment may
not accept this DO.EXE because DO is part of the batch file language.
Just rename DO.EXE in this case.
OS/2 only: Make sure that you have the EMX libraries installed.
Please visit ftp://ftp-os2.nmsu.edu/pub/os2/dev/emx/v0.9d
To instal the Linux version, copy the binary file DO to /usr/bin
and remember the capital letters. "do" with lowercase letters
is occupied on Unix systems.
sudo cp DO /usr/bin
MacOS does not allow to copy files to /usr/bin. If not already done,
create a directory ~/bin and generate a text file
~/.bash_profile
with the content:
export PATH="$PATH:~/bin"
and then simply copy DO:
cp DO ~/bin/
Remember the capital letters.
------------ Online Help ---------
Simply type DO without parameters.
------------ version history ----------
1.01: * wildcard at the end of expression ABC* did not work
1.02: new commands DO WAITFORDRIVE, DO ISDRIVEREADY, DO SOUND added
1.03: WHICHFIRST added
1.10: some bugfixes; (OS/2 only) moved from kbdvio32.dll to emx.dll
DO BATCH added
1.11, 1.12: minor bugfix
1.20: DO DELETE added
1.30: long file support > 2 GB added both for Windows and OS/2
Return values for DO WHICH
1.31: DO SIZE and DO LISTSIZE special functionality for WAV files
(added: file size in minutes)
1.43: Joker selection bug fixed
function ALBUM added
function UPLOAD added
1.46: locating and deleting clone files
making filenames 'flat' (subdir names in file names)
1.50: available for Linux and Mac
1.53: DO EVERY added
DO CONVTEXT added
1.99: DO COPY, DO PCOPY, DO REBUILD added
2.00: DO SORTDATE, DO SORTSIZE, DO SORTNAME added
basic syntax changed
- wildcard filenames can contain directories
- the source directory has to be entered first and separate from the files,
e.g. DO list C:\FROMTHISDIR\ *.txt *.doc
DO copy C:\FROMTHISDIR\ *.txt *.doc D:\TOTHISDIR\
2.00a: Fix: DO DISKSIZE, DISKFREE, DISKINFO did not work in 1.99-2.00 anymore.
2.01: DO CONDBATCH added
UPTO: added (opposite of SINCE:[DATE])
2.10: all error messages are now sent to stderr instead of stdout
fixed: if one file cannot be copied, DO COPY does not terminate anymore
and continues copying the next files.
------------ Functionality and usage ---------------
The syntax generally differs from commandline commands like "copy" or "dir":
- It is recommended to make the directory current from where you access the
files.
- The default behaviour is including all subdirectories:
DO LIST *.TXT
lists all files ending with .TXT in the current directory and all its
subdirectories.
- To omit searching in subdirectories, you have to use the dot command:
DO LIST . *.TXT
Most commands are related to files, but there are a handful commands which
are not.
General Syntax:
DO COMMAND [SOURCEDIR\] [.] [WILDCARD1 WC2... !EXCLUDE1 !EXCLUDE2] [TARGETDIR\] [ADDITIONALCOMMANDS:]
For most commands, you can type wildcard filenames. The default behaviour
of DO is to run through all subdirectories. No filenames means * (all files).
A single dot omits subdirs. SOURCEDIR and TARGETDIR has to end with \ or / (Unix).
Since DO 1.60, you can use filenames without wildcards * ?. Since DO 2.00,
you can enter directory names in the wildcard argument. You can use several
* and ? characters. Test a complicated selection with DO LIST.
To exclude wildcard filenames, enter a ! sign before.
DO LIST *mydir\* *mydir2\* !*.exe !*.pdf
lists all files in directories ending with "mydir" or "mydir2", but not files
with extension EXE or PDF.
By default, the files and subdirectories which are placed in the current directory
are processed. To enter another directory, enter a parameter with \
DO LIST C:\FROMTHISDIR\ *
Important is the ending \ - otherwise a filename is assumed.
On Windows and OS/2, entries are not case-sensitive, on Mac and Linux, it is case-
sensitive. On Unix systems (Linux, Mac), slash / instead of backslash \ is used.
DO writes the output to stdout and does not use escape sequences, so
you may route the output to a text file:
[C:\] DO LISTDIR >Directories.txt
creates a file "Directories.txt" containing all directory names
of drive C:
Functions:
*************
** drives ***
*************
(Windows and OS/2 only)
DO DISKFREE D: shows the free disk space of disk D:
DO DISKSIZE D: shows the size of disk D:
DO DISKINFO D: shows free disk space and size of disk D:
and ?: shows all drives
sample:
[C:\] DO diskinfo ?:
Drive C: 187 MB free (37%) of total 502 MB disk space
Drive D: 149 MB free (19%) of total 792 MB disk space
Drive E: 62.8 MB free (8%) of total 792 MB disk space
All sizes are shown with three valid digits, e.g. 99.9 MB or 111 GB.
******************
** directories ***
******************
DO LISTDIR lists all directories
DO SIZE D:\DIRECTORY
shows the size of all files in the directory (with subdirs)
DO TREE shows a directory tree
samples:
[C:\mydata] DO size
Size of C:\mydata\*.* is 310 MB
[C:\mydata] DO listdir
C:\mydata\mydir1
C:\mydata\mydir2
C:\mydata\mydir2\mysubdir1
C:\mydata\mydir2\mysubdir2
[C:\mydata] DO tree
mydir1
mydir2
mysubdir1
mysubdir2
*******************************************
** file selection options **
*******************************************
SINCE:MM-DD-YY
SINCE:DD.MM.YY
processes only files younger than the estimated file date.
UPTO:MM-DD-YY
UPTO:DD.MM.YY
processes only files elder than the estimated file date.
-nKB -nMB -nGB -nTB
(n = number)
processes only files not bigger than the estimated size.
nKB- nMB- nGB- nTB-
processes only files bigger than the estimated size.
ATTRIB:arhs
ATTRIB:ARHS
processes only files with specific attributes, while
capital letters means attribute is set and
lowercase letters means attribute is not set.
ATTRIB:Ah
processes all files where the Archive bit is set
and the hidden bit is not set.
*******************************************
** listing, files, file size, file date **
*******************************************
DO LIST shows full file name of all files
DO LISTSIZE shows full file name and size of all files
DO LISTSIZEDATE shows full file name, size and date
sample:
[C:\mydata] DO list
C:\mydata\mydir1\file1.txt
C:\mydata\mydir1\file2.cpp
C:\mydata\mydir2\mysubdir1\file1.txt
C:\mydata\mydir2\mysubdir1\file2.cpp
C:\mydata\mydir2\mysubdir2\file1.txt
C:\mydata\mydir2\mysubdir2\file2.cpp
[C:\mydata\mydir1] DO list .
C:\mydata\mydir1\file1.txt
C:\mydata\mydir1\file2.cpp
[C:\mydata\mydir1] DO list . *.cpp
C:\mydata\mydir1\file2.cpp
[C:\mydata\mydir1] DO listsizedate . *.cpp
C:\mydata\mydir1\file2.cpp (23.4 kB; 7-22-2013)
DO TYPE *.TXT prints all *.TXT files to stdout (with subdirs)
"DO TYPE" is similar to the default "TYPE" command, but runs through all
subdirectories:
[H:\prog] DO type *.c *.cpp >AllMyCfiles.txt
creates a big text file with the contents of all C and CPP text files
located in the H:\prog directory, including subdirectories.
Please note that such a command creates very big text files. Not every
text editor is able to handle such files. I've written powerful
freeware editors "ME" and "WSedit" which handles files up to 20 MB length.
Visit http://www.WriteAndSet.com
************************
*** SORTED FILE LIST ***
************************
You can created a sorted of your files:
DO SORTDATE * (and additional parameter see above)
DO SORTSIZE *
DO SORTNAME *
The order is descending with SORTDATE (newest first) and SORTSIZE
(biggest first). SORTNAME is ascending by alphabet, not case-sensitive.
To change the format of the date, you can add e.g.:
DATE:yyyy-mm-dd TIME:mm-ss-ampm
or a/p instead of ampm.
The file listing is sorted over all directories. The sort algorithm has
no limit and internally uses big and fast hash tables.
***********************
*** Copying files ***
***********************
Since DO 1.99, you can copy files. If the target file already exists,
it generally copies the file only if the source date is newer than
the target date.
Only with the FORCE: parameter, the files are always rewritten.
DO COPY [Wildcard filenames] X:\MYDIR\
copies all wildcard specific files of the current diretory separated
by space to X:\MYDIR\
including all subdirectories.
Instead of X:\MYDIR\ it is allowed:
X:MYDIR X:
while the current directory is added behind X:
Besides drive letters, the ending backslash is required, otherwise
an error message will occur.
DO COPY
prints every copied filename to screen
DO PCOPY
(progress copy) does not print filenames, instead you will get
a progress bar.
DO DCOPY
(dummy copy)
is like DO COPY, but does not really copy the files, but shows
the filenames like DO COPY.
Use DO DCOPY to see what happens and to test the correct syntax.
DO COPY/PCOPY
- generally collects the files first
- does not query when overwriting files !
- does not perform the copy action if the file age of the
target is the same or newer than the source file date.
- reads and writes big files in 20 MB steps.
Normally, DO COPY checks the available space at the target disk and
does not start copying if not enough space is available. With TRY:
this warning is still shown, but copying is tried anyway.
HANDLING FILES > 4GB
When copying files with size bigger than 4 GB, copying normally
fails when using FAT32 file system.
To successfully perform copying, add the FAT32: parameter:
DO COPY *.mp4 X:\MYDIR\ FAT32:
All files bigger than 4 GB will be copied into smaller parts:
MOVIE.MP4 (10 GB)
will be copied to:
MOVIE.MP4 (0 Bytes)
MOVIE.MP4.part001 (4 GB)
MOVIE.MP4.part002 (4 GB)
MOVIE.MP4.part003 (2 GB)
Do not delete the 0 Bytes file with the original file name
which is needed for rebuilding the file.
Instead of a fixed 4 GB splitting size with FAT32:, you can
set an arbitrary splitting size:
SPLIT:100MB
Any values without dot/comma are supported.
The possible factors are: KB,MB,GB,TB
**************************
** REBUILD parted files **
**************************
DO REBUILD
rebuilds all parted files in all subdirectories. The parted
files are not deleted.
Do only perform DO REBUILD of 4GB parts on non FAT32 files,
of course.
DO DELETE *.part???
deletes the parted files.
************************
** setting attributes **
************************
(Unix does not know file attributes, Windows and OS/2 only)
DO SETATTRIB SETATTRIB:ARSH *
is like the "ATTRIB" command. It sets the file attributes.
A Archive
R Read Only
S System
H Hidden.
Captial letters enable the attribute, lowercase letter disable it.
Combinating with the SINCE: switch enables you executing setting
attributes for all files with a specific date or later.
You can combine the command with the copy command:
DO COPY SOURCEATTRIB:a TARGETATTRIB:A *.txt C:\TARGETDIR\
means that the source file attribute "archive" is turned off,
while the archive file attribute of the target file (the copied file)
is turned on.
SOURCEATTRIB: and SETATTRIB: is used similar.
***********************
** listing WAV files **
***********************
[D:\AUDIO\MYSONGS] DO SIZE *.WAV
Size of D:\AUDIO\MYSONGS is 778 MB
number of tracks: 38
length in minutes: 77.1
length in minutes with 2sec pause between tracks: 78.4
Normally, a CD-ROM holds 74 or 80 minutes of music. Here you can see if
the *.WAV files fits to a CD or not.
2sec pause between the tracks is an extra feature of CDrecord.
[D:\AUDIO\MYSONGS] DO LISTSIZE *
If a WAV file is found, you'll additionally get the file size in minutes.
*****************
** text search **
*****************
DO SEARCH requires wildcard filenames.
DO SEARCH String1 String2 ... searches String1 or String2 ...
DO SEARCHLIST writes only the filename, not the occurences of the string
DO SEARCHLISTNO writes only the filename if the string has not been located
samples:
[H:\prog] DO search *.cpp "void mess"
H:\prog\4allcalc\messrec.cpp
(48) void MessRecStart () {
(53) void MessRecEnd () {
H:\prog\sibyl\Ctest\messrec.cpp
(48) void MessRecStart () {
(53) void MessRecEnd () {
The line number is shown in parenthesis. If you want to see only the
filenames and not the line occurrences, type SEARCHLIST instead of SEARCH.
[H:\prog] DO search *.pas *.cpp void OR procedure
shows all lines in *.pas and *.cpp files (also in subdirectories) which
contain the expressions "void" or "procedure".
[H:\prog] DO search *.cpp void AND mess
shows all lines in *.cpp files which contain both "void" and "mess".
[H:\prog] DO search *.cpp void ANDNOT mess
shows all lines in *.cpp files which contain "void", but not "mess".
DO SEARCH does not search the following (binary) file types:
EXE, DLL, DRV, OBJ, MET, COM, SYS, PDF, PSF, HLP, INF,
OS2, DMP, LIB, ICO, INF, RES, GIF, JPG, BMP, PCX, TIF, SRF
DO SEARCH is case-INsensitive. That means, if you search "THIS" and
DO finds "this", the line will be shown.
DO SEARCH does not support more than two search strings as parameters.
*******************************
** count lines in text files **
*******************************
DO COUNTLINES *.txt
counts the lines of all txt files. The line end coding is OS specific.
***************************************
***************************
** count number of files **
***************************
DO COUNT *
simply counts the number of files. Directories are not counted, only files.
** manipulating file names and dates **
***************************************
DO LOWERCASE, UPPERCASE, CAPITAL changes the case of files:
file.txt, FILE.TXT, File.txt
DO NOUMLAUTS changes the german umlauts to normal characters, and others to
the "x" character (in the filename, not in the file).
DO TIME:HH.MM changes the file time, but leaves the file date unchanged
DO DATE:MM-DD-YY or DATE:DD.MM.YY changes the file date, but leaves the file
time unchanged
Before manipulating files, it is useful to test your wildcard parameters
with DO LIST.
*****************************
** manipulating text files **
*****************************
DO CONVTEXTANSI-OEM *.txt
converts all *.txt files including all subdirectories from ANSI to OEM codepage.
UTF8 is also available. The old text files are renamed to *.tmp. All possible
directions are available. All combinations are available (ANSI-OEM, OEM-ANSI
and so on).
You can combine COPY and CONVTEXT functionality:
DO COPY *.txt d: CONVTEXT:ANSI-OEM
In this case, the files are copied and the target file name is the same. The
conversion is only processing if the file date of the source is newer than
the file date of the target.
DO COPY *.txt d: CONVTEXT:ANSI-OEM TO:*.doc
same as above, but changes the extension of the target file.
TO: requires a following "*.".
********************
** locate progams **
********************
(In Unix, use "which" directly instead.)
DO WHICH PROGRAMNAME shows full filename of progs which will be executed
"Do which" searches the files *.exe, *.com, *.bat, *.cmd in all directories
of your PATH environment variable.
sample:
[C:\mydata] DO which DO
H:\SOFTWARE\SHARE\PATH\do.exe (85.4 kB; 5-29-2014)
h:\software\cdrecord\cdx\do.exe (73.0 kB; 5-8-2014)
DO WHICHFIRST shows only the first occurence, and only the filename:
[C:\mydata] DO which do
H:\SOFTWARE\SHARE\PATH\do.exe
If no file has been found, DO returns errorlevel 1, otherwise 0.
**************************
** usage in batch files **
**************************
DO WAIT n waits for n seconds
DO WAIT hh:mm waits for daytime hh:mm
DO SOUND n plays interal speaker c-major sound, n can be odd or even (msec)
DO SET NAME reads environment variable NAME from stdin and writes temp.cmd
DO WAITFORDRIVE D: waits for availability of drive D: (removable media)
DO BATCH *.in [*.out] [startstring] [endstring] for creating batch files
DO WAIT 0.450
*************
waits for 450 milliseconds.
"DO WAIT" is useful for e.g. a batch file in the startup folder. The batchfile
has to wait e.g. 30 seconds before executing tasks which require that the
computer has finished the boot process. Floating point values are supported,
e.g.
DO WAIT 23:59
*************
waits until one minute before midnight.
DO WAITFORDRIVE F:
******************
waits for availability of drive F:. After inserting the disk, especially
CD-ROM drives need some seconds to get available. If a batch file aleady
proceeds its job, the job will fail because the drive is not ready (yet).
To abort waiting, press Ctrl-C
DO ISDRIVEREADY F:
******************
returns 0 if the drive is ready (that means no error) or 1 if the drive is not
ready. You have to use the ERRORLEVEL command in a batch file:
do isdriveready F:
if errorlevel 1 goto NOT_HERE
echo Drive F: is available
goto end
:NOT_HERE
echo Drive F: is not available at the moment
:end
DO EVERY
********
DO EVERY 3 days
returns 0 the first time.
If the same command is repeated 0, 1 or 2 days later, DO returns 1
After the 3rd day, DO returns 0. The time difference is relevant,
not the date. 3 days does not mean from Monday to Thursday, instead
the acurate period of 3 x 24 h is relevant.
Purpose: You can execute additional commands in a batch file:
do every 3 days
if errorlevel 1 goto NOT_STORING
echo now saving SSD to HD
xcopy ........
xcopy ........
goto END
:NOT_STORING
echo skip storing SSD to HD
:END
To remember the date when it returns 0, DO EVERY writes a file "do-every-3-days"
in the current directory, so the current date is saved.
Also valid: minutes hours days weeks months years
DO SOUND 10
***********
plays a c-major sound by using the internal speaker. Odd numbers play c-e-g-c'
and even numbers play the reverse sound c'-g-e-c. The higher the number, the
slower the sound.
DO SET
******
"DO SET" is required if you want to set an environment variable with a value
which has been processed to stdout by another commandline program.
E.g. the "ADD.CMD" batch file in the BatchBurn package (BatchBurn is a set of
batch files for use with CDRECORD commandline CD burn software) uses "do set":
cdrecord -msinfo dev=%CD_BUS% >cdinfo.txt
do set cd_info <cdinfo.txt
call temp
del temp.cmd
"cdrecord" sends an address string where the current CD-ROM data ends to stdout:
cdrecord -msinfo dev=%CD_BUS%
21098,30989
and this address is saved in the file "cdinfo.txt".
do set cd_info <cd.info.txt
simply writes a batch file temp.cmd with the contents:
@set cd_info=21098,30989
So "do set" simply adds some strings and creates a file "temp.cmd". That's all.
DO BATCH
********
DO BATCH requires wildcard filenames.
"DO BATCH" is useful if you want to run a program (e.g. a file converter) for
a lot of files, and the program does not understand wildcards.
Principally, "DO BATCH" is similar to DO LIST:
[C:\] DO list *.txt
mydoc1.txt
mydoc2.txt
subdir\otherdoc1.txt
subdir\otherdoc2.txt
"DO Batch" let you add additional strings before and behind the filename:
[C:\] DO batch *.txt "startstring" "endstring"
startstring mydoc1.txt endstring
startstring mydoc2.txt endstring
startstring subdir\otherdoc1.txt endstring
startstring subdir\otherdoc2.txt endstring
Please use the " characters, otherwise spaces in "startstring" are not valid.
If you add a second wildcard, the filename gets repeated with the second
file extension:
[C:\] DO batch *.wav "startstring" "endstring" *.mp3
startstring mymusic1.wav endstring mymusic1.mp3
startstring mymusic2.wav endstring mymusic2.mp3
Now all this is useless until you send the stdout to a batch file:
[C:\] DO batch *.wav "gogo -b 128" *.mp3 >MakeMP3.cmd
[C:\] type MakeMP3.cmd
gogo -b 128 mymusic1.wav mymusic1.mp3
gogo -b 128 mymusic2.wav mymusic2.mp3
DO CONDBATCH
is the same as DO BATCH, but the line is only written if the *.out file
does not exist yet. Execution of a DO BATCH generated cmd file let the
output file overwrite.
*** DO ALBUM *.JPG **********
DO ALBUM *.JPG creates a HTML file where all the listed files are embedded.
*** DO UPDATE *.ZIP *************
creates an input file for FTP.EXE which contains the commands for uploading
the listed files.
*** DELETING FILES ****
W A R N I N G !!!
This functionality can dramatically cause harm with little input!
Test the wildcard names with DO LIST before !!!
DO DELETE *.txt
deletes all files ending with ".txt" in the current directory and its
subdiretories.
To be sure that the files are correctly specified, type the same command
with LIST before using "DO DELETE":
DO LIST *.TXT
DO DELETE won't delete files in read-only mode, but this does
DO DELETEHARD
DO DELETEDIR also deletes empty directories and
DO DELETEHARDDIR deletes read-only files and empty directories.
To run deleting files in quiet mode, enter a Q:
DO DELETEQ
DO DELETEHARDQ
DO DELETEHARDDIRQ
In this case, every deleted file will be prompted with a single dot instead
of the full filename.
*** LOCATING CLONE FILES ***
DO SHOWCLONE *
shows all files which exists two times in the current directory and its
subdirectories. This functionality is based on a comparison of the file
content, not of the file name or date. The clone is the file which alpha-
betical filename is higher than the base file.
DO KILLCLONE *
kills the clone. Use SHOWCLONE first to confirm the proper function.
*** MAKING DIRECTORIES WITH FILENAMES "FLAT" ***
Before copying files e.g. to an MP3 player, it can be useful to substitute
the directory structure by a longer file name.
DO FLAT *.MP3
moves all MP3 files of all subdirectories into the current directory and
changes the name SUB\SUBSUB\MYMUSIC.MP3 to SUB_SUBSUB_MYMUSIC.MP3.
*** OPERATIONS FOR CD-ROM DRIVES (OS/2 only) ***
DO EJECT X:
DO OPENCLOSE X:
DO OPENCLOSE X: 15 opens, waits 15 sec, closes (default is 3 sec)
DO RESET X:
DO EJECT X: seems not to work with USB drives.
|
Commenti
Martin Iturbide
Dom, 02/07/2023 - 22:30
Collegamento permanente
New Link: https://hobbes.nmsu
Aggiungi un commento