![]() | |
|
Welcome to the ABXZone Computer Forums forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 |
| ~Not an Expert~ Join Date: May 2002
Posts: 1,678
| Hello again my friends at ABXZONE. It's been a while since my last visit, but I've come to depend on the experts here to help, when no other help is available. I am trying to convert an OS/2 command file (.CMD) to work on Win9x, Win2k and WinXP. The problem is that with OS/2, there are functions (via REXX) that are not available in standard windows .BAT files. To further complicate things, utility programs (XBATCH, KIX, etc) cannot be loaded on the Windows machines. PROBLEM: Copy file <anyfile>.DAT file to a sub-directory for archiving. There is the possibility that this .BAT file will be run multiple times in one day, so the filename must be unique with each execution. The OS/2 REXX (.CMD) file, took the current date and time, removed the "/" from the date and the ":" from the time, and made the filename with what is left....example 09022004082637.DAT = MMDDYYYYHHMMSS.DAT. I have been able to put the current date and time into varables, but haven't been sucessfull in removing the "/" and ":" to make a valid filename. If you have any tricks or tips to do string manipulation in standard Windows .BAT files, PLEASE provide examples if you can. Jim
__________________ [ABX]-Kahn - "Keepin' Time!" |
| (Offline) | |
| Advertisement | [Remove Advertisement] |
| |
| | #2 |
| Registered User Join Date: Jan 2003 Location: Blue Ridge Mountains, VA
Posts: 384
| Date/Time parsing jcash, If you have command extensions enabled (by default, they are) on Windows XP or Windows 2000, the following will work to create the file name you're looking for. Code:
|
| (Offline) | |
| | #3 |
| ~Not an Expert~ Join Date: May 2002
Posts: 1,678
| Thanks for the quick reply! I tried this code on a Windows 98SE machine and get a Syntax error. I'm not sure exactly how this should work, but let me take a guess. It is trying to "token-ize" the results of 'ECHO %time%' using the ":" as a deliminator. I don't see how the variables %b and %c are set or what the "/f" does. Perhaps it won't work on Win98? Thanks Jim EDIT: it works perfectly in WINXP.....
__________________ [ABX]-Kahn - "Keepin' Time!" |
| (Offline) | |
| | #4 |
| Linux user Join Date: Jul 2002 Location: Montreal
Posts: 4,074
| Can't help you with this one ... I just wanting to say hi ![]()
__________________ |
| (Offline) | |
| | #5 |
| Registered User Join Date: Jan 2003 Location: Blue Ridge Mountains, VA
Posts: 384
| Ooops. Jim, It won't work on 98. Several of the features used here are command extensions added in NT/2000. I missed the bit in your message where you needed it to work under 98. Sorry about that. That said, Windows 98 is a lot more difficult. The batch language on that particular OS is as crippled as it gets. I HAVE seen date and time parsers that didn't use any external process for Windows 98, but they're nasty, and would have to be customized (if you can follow the obfuscated batch code) for what you want. You can look here: http://www.pressroom.com/~tglbatch/pdate.html for something that works (supposedly -- I have no way to test it) in Windows 98. Personally, I'd create a very small program that you can execute that will write out the correct formatted date and time to stdout. Oh yes -- how the original works. When you do a for /f, you invoke a parser that processes each line of input (if there were multiple lines returned by the command, each one would be processed). The variable name you pass is actually the FIRST name, which gets the value of the first parsed token. Each subsequent parsed token goes to name+1 (character wise). So, if you use %%x, the variables would be x, y and z. Under XP or Windows 2000, you can just type in 'help for' at the command line, and it will show you the syntax information for this. Logan |
| (Offline) | |
| | #6 |
| The Shade of Lazarus Join Date: Jun 2002 Location: PM me to keep in contact
Posts: 26,003
| Sorry Jim....I didn't get here until late in the game. I think the link Logan posted will work well...it claims to work with Win98. If you take that and either use the parsed date/time to append to each file name or create a subdirectory with that name to copy files in to you should be good I think. |
| (Offline) | |
| | #7 |
| Registered User Join Date: Jul 2004 Location: Indiana
Posts: 63
| For a scripting language that works on Win9x and up, check out Kixtart: http://www.kixtart.org/ Plenty of examples and such there. If you need further help with it, just ask Also, REXX for Windows: http://www.quercus-sys.com/prexxw35.htm |
| (Offline) | |
| | #8 | |
| The Shade of Lazarus Join Date: Jun 2002 Location: PM me to keep in contact
Posts: 26,003
| Quote:
| |
| (Offline) | |
| | #9 |
| ~Not an Expert~ Join Date: May 2002
Posts: 1,678
| Hello Yamawho. Glad to see you are still here. Thanks to Logan and ChrisD and the "King Termite" for your replies.... but...(there is always a butt, and it's usually me)...but I can't add any scripting language processors to these machines, and "whatever" must work with Win98, Win2K, and WinXP without modification....That said, I came up with a solution...it will even work in DOS, and OS/2. I used an inline QBASIC program (Qbasic was distributed by Microsoft on the Windows Resource Kits, so our corporate watchdogs with their fancy detection software bypassed it). If anyone is interested in the code, I can post it on Friday.
__________________ [ABX]-Kahn - "Keepin' Time!" |
| (Offline) | |
| | #10 |
| Registered User Join Date: Jan 2003 Location: Blue Ridge Mountains, VA
Posts: 384
| QBasic Jim, QBasic isn't distributed as part of XP, though... I know you can install it by copying it off of a 98 CD, but this isn't that much different from installing REXX, or a simple time utility. Logan |
| (Offline) | |
| | #11 |
| ~Not an Expert~ Join Date: May 2002
Posts: 1,678
| I didn't actually "INSTALL" QBASIC on any machine. We have a common "SOFTWARE" network share that now has the "QBASIC.EXE and QBASIC.HLP" files. In my .BAT procedure, I just execute QBASIC from the utility directory on the server, and don't load it on each machine. This snip of code sets an enviornment variable "FILENAME" to be MMDDYYYHHMMSS.DAT. Code:
__________________ [ABX]-Kahn - "Keepin' Time!" |
| (Offline) | |
| | #12 |
| Join Date: Jan 2004
Posts: 605
| Holy crap, there's a lot of extra stuff the FOR command can do under XP. Shame I didn't have that power in the DOS/Win9x days! Nowadays of course for repetive functions and stuff I just write stuff in VB.
__________________ OS Microsoft Windows XP Professional Service Pack 2 CPU Intel Pentium 4 3.0 GHz with HT (Northwood) Motherboard ASUS P4P800 Deluxe RAM 1 GB Kingston DDR400 3-3-3-8 Dual Channel Display NVIDIA GeForce 6600 GT 256 MB AGP Monitor 17" Mitsubishi Diamond View 1770 FD Sound SoundMAX Digital Audio Speakers DKL 3D-650 NIC 3Com Gigabit LOM Modem Marconi FLX Stream-ISG HDD Maxtor DiamondMax Plus 9 120 GB HDD Maxtor DiamondMax Plus 9 200 GB Optical SONY CRX300E CD-RW/DVD-ROM Optical SONY DWD18A DVD±RW Case AOpen KF45A-P4 PSU LC-B400ATX Keyboard Microsoft Internet Keyboard Mouse Microsoft Wheel Mouse Optical |
| (Offline) | |
| | #13 | |
| Registered User Join Date: Jan 2003 Location: Blue Ridge Mountains, VA
Posts: 384
| Quote:
Logan | |
| (Offline) | |
![]() |
| Thread Tools | |
| Display Modes | |
| |