tscmd35.zip Useful NT/2000/XP script tricks and tips


Timo Salmi

Sat 11-Feb-2006: Released an update

153350 Feb 11 2006 ftp://garbo.uwasa.fi/pc/link/tscmd.zip
tscmd35.zip Useful NT/2000/XP script tricks and tips, T.Salmi

Added three new FAQ items
129} Is it possible to stop and reset the print spooler with a script?
130} How do I find and delete files which contain a specific text?
131} How to get the language of Windows XP in a script ?

Added further alternative solutions to a couple of the old items.

The current set of the FAQ items with 1CMDFAQ.TXT is
1} How to get today's date elements into environment variables?
2} On Windows XP how do you stop the script files from closing?
3} How can I customize the Command Prompt Window with script commands?
4} How can I test is it on MSDOS/Win3..9x/Me or NT/2000/XP?
5} How do I get a fully qualified path name of my script?
6} How does one get yesterday's date?
7} How can I test if two files agree in size and datetime stamp?
8} How do I find all the files made at of after YYYYMMDD HHMM?
9} How can I suppress script error messages altogether?
10} How can I change the environment variable values within a FOR loop?
11} How do I retain my original code page in these scripts?
12} How can I rename all my .JPG files sequentially in a folder?
13} How do I get the current day of the week?
14} Help! My old batch files won't work since there is no choice.com
15} Is it possible to echo without linefeed like the Unix echo -n?
16} How can I get the time without having to press enter?
17} How can I avoid the potential "ECHO is off." in echoing %myvar%
18} How does one build re-usable script function modules?
19} How can one build a delay / sleep / wait procedure for a script?
20} Is is possible to right-justify numbers or words in a script?
21} Do you have pointers to additional script material and tips?
22} How do I capture the current folder name into a variable?
23} How do I get the n'th, the first and the last line of a text file?
24} How do I get the m'th item on the n'th line of a text file?
25} How can I quote with e.g. "> " an entire message?
26} How do I get the length of a string into a variable?
27} How can I remove all the blank lines from a text file?
28} How to convert a file written in IBM PC characters into LATIN1?
29} How do I drop the first two characters of a string, and so on?
30} Can one calculate the difference between two times in a script?
31} How many days ago was 31.12.2003? What date was it 100 days ago?
32} How can I convert a decimal number to binary, octal, hexadecimal?
33} How can I convert a binary, octal, hexadecimal into a decimal?
34} How can I remove the quote characters from a line?
35} How can I substitute the second field on each line of my file?
36} I start a program from my script and it hogs my command window.
37} How can I insert a line in the middle of a file with a script?
38} How can I set and test the errorlevel within a script file?
39} Is there a subroutine to convert a variable into uppercase?
40} How do I get the number of arguments given to a script?
41} How can I create a zero-byte file? How do I test for it?
42} What is the subroutine for testing a filename for wildcards?
43} Is there a way of counting the number of files in a folder?
44} How do I get the first 68 columns from a text file?
45} How can I find out how many days old a file is?
46} Is a program available in the default folder or at path?
47} Is it possible to echo the redirection symbol in a script?
48} Why do some comment lines cause errors? What can I do about it?
49} I need to reverse a text file. How do I do that fairly quickly?
50} How do I get the position of a substring in a string?
51} How can I echo lines in different colors in NT scripts?
52} How can I enter a password into a variable without echoing it?
53} How can I test if a disk device is ready or not?
54} How can I get the type of a disk device?
55} How to get the creation, last modified and last access of a file?
56} How to find and move more recent files from one folder to another?
57} How do I get a list of all my empty folders on c:\ ?
58} How do I best combine two quoted arguments into one quoted string?
59} How do I find if a folder exists? How about visible files in it?
60} How do I delete all but most recent 20 files in a folder?
61} How can one devise a command line calculator?
62} How can I compare within a script if two files are identical?
63} How to perform a command on each line of file as an argument?
64} How to count the number of lines in a file, empty lines inclusive?
65} How do I add text in front and after each line in a text file?
66} How can I delete all the hidden Thumbs.db files from my system?
67} Is it possible to send a variable value to the clipboard?
68} How can I test if a program already has been loaded?
69} How do I get the first, or the last, 400 lines of a file?
70} Calendar elements: What weekday is December 31, 2004?
71} How can I reboot my computer from a command line script?
72} Is it possible to use quotes as delims in for loops?
73} How can I convert a hexadecimal string into an ASCII string?
74} How can I compare two numbers that have decimals with IF?
75} How do I detect if an object is a file or a folder?
76} How do I create an empty file? How can I detect the empty files?
77} How do I list the files in \All Users\Desktop in the short format?
78} Is it possible automatically to record my logon times into a file?
79} How can I trim leading and trailing spaces?
80} How can I extract the last part of a path such as C:\ABC\DEF\GHI\?
81} Is there a script to capitalize all the words in a text file?
82} Why does echo 9>temp.txt fail while echo 10>temp.txt works?
83} How to archive files with a rotation of five latest generations?
84} How can I automate downloading files from an ftp-site?
85} How to test if a folder contains any files with long names?
86} How to put each line of a text file into an environment variable?
87} How can I create a four-digit random string?
88} How to convert DEC to HEX with a script file, and vice versa?
89} All of a sudden "echo." doesn't work any more. What's wrong?
90} How do I get the most recent file within a directory structure?
91} How do I get command-line reference help?
92} How do I play a sound or a tune from the command line?
93} How do I check if my script was given a parameter?
94} Can I send the script's output both to the screen and a log file?
95} How to perform an operation on all the filenames listed in a file?
96} Can one use a script to columnize a comma separated values file?
97} I need to remove duplicate entries from the output or a file.
98} How do I equate all zip files with the date of their latest file?
99} How do I "touch" a file to update its last modified datestamp?
100} How can I identify and copy the five latest files from a folder?
101} How to capture Volume Serial Number into an environment variable?
102} How can I extract the individual bits from a decimal byte?
103} How do I exit a loop by pressing a key?
104} How can one remove double quotes from a script variable?
105} How to detect whether or not a folder contains hidden files?
106} How to test whether a variable is a non-negative integer?
107} How to do non-trivial renaming such as IMG*.jpg to IMG_*.jpg?
108} How can I execute a script one line at a time to debug it?
109} How do I open e.g. three separate instances of notepad at one go?
110} Can I use a script to determine if a specific printer exists?
111} How can I detect if a folder is shared or not?
112} Help, an old program fails to run since I have no floppy drive.
113} How do I find all *.TXT files on the C: drive sorted by size?
114} How do I pick a file's lines that are three characters long?
115} How can I decompose the path to be one folder per line?
116} How do I get a list all the *.BAT files which are at path?
117} Is it possible to get the physical memory from the cmd?
118} How to handle irregular empty fields of a CSV file?
119} How can I remove any leading zeros from an unsigned integer?
120} How do I use AND/OR/XOR/NOT operators in an IF statement?
121} How do I make a simple reminder to pop up on the desktop?
122} How to get a list files present in folder A but not in folder B?
123} How to test if a file is in a folder or below two or more times?
124} How do I find files which do NOT contain the search string?
125} How do I get the age of a file? Or of the files in a folder?
126} How do I grep for a line with a tab?
127} How can I pad leading zeros or like to a variable?
128} How to prevent SET /P input from entering the command history?
129} Is it possible to stop and reset the print spooler with a script?
130} How do I find and delete files which contain a specific text?
131} How to get the language of Windows XP in a script ?

The file contents of ftp://garbo.uwasa.fi/pc/link/tscmd.zip is
Filename Comment Date Time
-------- -------------------------------- ---- ----
1CMDFAQ.TXT NT/w2k/XP script tricks and tips Feb-11-2006 09:33:12
CHOOSE.EXE Ask questions in script files Dec-11-2003 05:33:38
COLORMAP.CMD Display ECHOC.EXE color map Jul-09-2005 19:08:16
COMPFOLD.CMD Compare contents of two folders Jan-26-2006 09:13:18
DATE2NUM.EXE Date into a Julian date number Oct-16-2004 11:52:32
DELE.CMD Recoverable command-line delete Jan-13-2006 01:00:20
ECHOC.EXE Echo in colors Jan-25-2004 09:10:30
EDATE.CMD Some alternative date formats Dec-04-2005 06:56:02
FILEAGE.CMD Find out how old a file is Jul-09-2005 19:17:12
FILEINFO.CMD CMD shell for FILEINFO.VBS Jul-09-2005 18:54:30
FILEINFO.VBS FileInfo Visual Basic Script Feb-26-2004 15:09:12
FILE_ID.DIZ Brief characterization of TSCMD Nov-16-2003 09:29:00
FULLNAME.CMD Display the full name of a file Sep-03-2005 19:34:12
MAILDATE.CMD Build a message's "From" header Oct-09-2005 10:52:44
M_TSCMD.CMD Makefile that built this package Feb-11-2006 08:32:42
NAMEDOWN.CMD Covert a filename to lower case Sep-01-2005 22:07:34
NAMEUP.CMD Covert a filename to upper case Sep-01-2005 22:07:46
NUM2DATE.EXE A Julian date number into a date Oct-16-2004 11:20:50
RECENT.CMD CMD shell for RECENT.VBS Jul-09-2005 19:03:08
RECENT.VBS Search folders for recent files Sep-07-2004 15:29:38
SAMENAME.CMD Find same name files in folders Dec-31-2005 20:57:06
TSCMDIDX.TXT The questions index separately Feb-10-2006 10:18:42
TSCMDINF.TXT Document (a readme) for TSCMD Feb-11-2006 08:33:14
TSCMDNWS.TXT News about the TSCMD package Feb-11-2006 08:36:06
TSPROG.TXT List of programs from Timo Salmi Jan-03-2005 09:48:38
WAKEUP.CMD A reminder desktop alarm clock Nov-03-2005 21:43:10
WHEREIS.CMD Find a file anywhere on a drive Sep-29-2004 05:01:02
XPMOVE.CMD CMD shell for XPMOVE.VBS Dec-31-2005 09:48:14
XPMOVE.VBS Move newer files between folders Dec-31-2005 09:51:14
---- ------ ------ -----
0029 492772

All the best, Timo

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question