Page 1 of 1
Command.com programming
Posted: 2004-01-17 01:34am
by StimNeuro
I'm trying to write a program in Command.com to quickly rename all the files in a folder to something that is dependent upon the file name. Unfortunately, I only know how to use higher level languages, like Java and limited C++, so I'm having a rough time just trying to figure out how they do an IF statement.
Does anyone know of a site where I can find the basics of the Comand.com language? I've tried Googling for it, but havne't turned up anything useful so far. Alternatively, is there a way to do this is Java?
Posted: 2004-01-17 02:31am
by Beowulf
Uou want to learn shell scripting? *shudder*
Better idea: get a copy of ActivePerl, and learn perl scripting. Alot more useful, and easier to learn. Plus, you can learn how to do CGI scripting as well...
EDIT: fixed typos...
Posted: 2004-01-17 02:48am
by Crayz9000
It's called a DOS batch script, look it up. And the syntax that goes with it is HORRIBLY limited.
Posted: 2004-01-17 03:09am
by Beowulf
Crayz9000 wrote:It's called a DOS batch script, look it up. And the syntax that goes with it is HORRIBLY limited.
I should go to bed soonish, but there's a reason why I recommended Perl for this task. It's designed to make this sort of thing easy.
Posted: 2004-01-17 03:21am
by StimNeuro
Thanks Crayz. I googled that term and found alot more useful sites.
Posted: 2004-01-17 03:41am
by StimNeuro
Problem finished without having to resort to using batch scripts. Simply sent the list of files to a text file, using dir/b, then added 'rename' in front of them and added the new name of the files with the Replace command. I knew about the /w, and /p switches, but never knew about the /b... How many bloody switches does that simple command have?
Posted: 2004-01-17 04:01am
by Crayz9000
StimNeuro wrote:Problem finished without having to resort to using batch scripts. Simply sent the list of files to a text file, using dir/b, then added 'rename' in front of them and added the new name of the files with the Replace command. I knew about the /w, and /p switches, but never knew about the /b... How many bloody switches does that simple command have?
dir /h
I think.
Posted: 2004-01-17 04:08am
by StimNeuro
Heh, just started going through through the alphabet..
Valid: /a, /b, /c, /d, /l, /n, /o, /p, /q, /s, /t, /w, /x.
Note: Try /s. I thnk it does a dir on every folder on your drive.. or something. Either way, it goes on for almost a minute, switching directories on its own.
Why in the world do they have so many switches? Surely they have to have a purpose...
Posted: 2004-01-17 05:28am
by Crayz9000
You would have thought that Microsoft would have realized the utility of a MAN command years ago. But noooo....
Anyway, I have an old DOS 3.0 book in one of my bookshelfs. I'll have to drag it out and have a look.
Posted: 2004-01-17 07:53am
by Xon
StimNeuro wrote:How many bloody switches does that simple command have?
Shit loads
"dir /?" is a good starting point.
Infact for any microsoft command line application, "/?" is a good switch to try first.
DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N]
[/O[[:]sortorder]] [/P] [/Q] [/S] [/T[[:]timefield]] [/W] [/X] [/4]
[drive:][path][filename]
Specifies drive, directory, and/or files to list.
/A Displays files with specified attributes.
attributes D Directories R Read-only files
H Hidden files A Files ready for archiving
S System files - Prefix meaning not
/B Uses bare format (no heading information or summary).
/C Display the thousand separator in file sizes. This is the
default. Use /-C to disable display of separator.
/D Same as wide but files are list sorted by column.
/L Uses lowercase.
/N New long list format where filenames are on the far right.
/O List by files in sorted order.
sortorder N By name (alphabetic) S By size (smallest first)
E By extension (alphabetic) D By date/time (oldest first)
G Group directories first - Prefix to reverse order
/P Pauses after each screenful of information.
/Q Display the owner of the file.
/S Displays files in specified directory and all subdirectories.
/T Controls which time field displayed or used for sorting
timefield C Creation
A Last Access
W Last Written
/W Uses wide list format.
/X This displays the short names generated for non-8dot3 file
names. The format is that of /N with the short name inserted
before the long name. If no short name is present, blanks are
displayed in its place.
/4 Displays four-digit years
Switches may be preset in the DIRCMD environment variable. Override
preset switches by prefixing any switch with - (hyphen)--for example, /-W.
copy & paste is so handy.
Posted: 2004-01-17 03:12pm
by phongn
Crayz9000 wrote:You would have thought that Microsoft would have realized the utility of a MAN command years ago. But noooo....
Try "help dir," it's the rought equivilant to MAN for built-in commands.
Posted: 2004-01-17 03:15pm
by phongn
This site seems to have a bunch of useful links. Be aware that the NT command interpreter (CMD.exe) is more powerful than the old DOS one (command.com). If you've got NT, use the former, not the latter.