Avatar of ToddRod_Taylor
ToddRod_TaylorFlag for United States of America

asked on 

MS-DOS batch that works in W2k and up - but not Win95

I have this batch working magnificantly in Windows 2000 and 2003 and XP with the help of the Experts here; but not in Win95!  What do I need to change in order to make this batch work under Win95, and, determine which OS it is running under and work accordingly?  I will never use anything older that Win95.

I suspect it is the for statements?

@echo off
setlocal

CD \RMS\C001\DL
COPY C:\GEMCOM\BACKUP\01VERIFO.DAT C:\RMS\C001\DL\01VERIFO.DAT
COPY C:\RMS\C001\DR\DRSA* C:\RMS\C001\DL\DRSA*

for /f "tokens=1,* delims==" %%a in ('type "C:\PDIMSG32\PDIMSG32.PMC" 2^>NUL') do if /i "%%a"=="Storeid" set locvar=%%b&goto FOUNDIT

echo NO store ID !!
pause
goto :EOF

:FOUNDIT
for /F "tokens=1-4 delims=/- " %%a in ('date/T') do set date=%%d%%c%%b
for /F "tokens=1-4 delims=/- " %%a in ('date/T') do set /a DAY=%%b

set /a YESTERDAY = DATE - 100

if  "%DAY%" == "1" (
     set YESTERDAY=%DATE%
)else (
     set YESTERDAY = DATE - 100
)

set drdate=%yesterday:~6,2%%yesterday:~4,2%
set locvar=%locvar:~-3%
echo %locvar%
echo %drdate%

for /f "delims=" %%a in ('dir /b /a-d DRSA*.') do call :PROCESS "%%a"
goto :EOF
:PROCESS
set FileName=%~nx1
rename "%FileName%" "%locvar%%drdate%.P%FileName:~4%"
:EOF

Windows BatchMicrosoft DOSWindows OS

Avatar of undefined
Last Comment
SteveGTR
Avatar of b0fh
b0fh
Flag of United States of America image

Likely something to do with the way that the date was displayed prior to Y2k.  

write a test script to echo the date and see how it compares to your other machines... then alter the script accordingly.
Avatar of SteveGTR
SteveGTR
Flag of United States of America image

You'll have to go old school to get this done. Here's a way to get the store ID:

@echo off

if not "%1"=="" goto STARTPROC

echo Usage: %0 fileName
goto EXIT

:STARTPROC

set fileName=%1
set storeId=

echo @set storeId=%%1 >storeid.bat

find /i "storeid" %fileName% >_temp.bat

call _temp.bat 2>NUL

echo storeId=%storeId%

del _temp.bat 2>NUL
del storeid.bat 2>NUL

:EXIT
Avatar of ToddRod_Taylor

ASKER

Ah, that is but one piece of the puzzle

1.  The SETLOCAL command is invalid

2.  The first For command just says Syntax error

3.  The Date /T doesn't work, (DATE outputs 02/28/2007, then prompts for a date) DATE does not accept any parms other than a new date; so, how do I get the date here?

Avatar of SteveGTR
SteveGTR
Flag of United States of America image

Here's the old school way to get the date:

@echo off

echo.|date>_temp.bat

find "The current date" _temp.bat>NUL
if ERRORLEVEL 1 goto OldVer

echo @set curdate=%%5>the.bat

goto GetDate

:OldVer

echo @set curdate=%%4>current.bat

:GetDate

call _temp.bat

echo Current date: %curdate%

del _temp.bat>NUL
if exist the.bat del the.bat>NUL
if exist current.bat del current.bat>NUL
Avatar of ToddRod_Taylor

ASKER

SteveGTR,

ok, the getloc batch works except I also need:   storeid=%storeid:~3%
but that doesn't work

testing getdate....
ASKER CERTIFIED SOLUTION
Avatar of SteveGTR
SteveGTR
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of ToddRod_Taylor

ASKER

getdate isn't working:

the _temp.bat file says:

Current Date is Wed 02-28-2007
Enter new date (mm-dd-yy):


ERRORLEVEL is  not 1, so it is executing the "current.bat"
current.bat files says:

@set curdate=%5

Avatar of SteveGTR
SteveGTR
Flag of United States of America image

Just run this:

@echo off

echo.|date>_temp.bat

echo @set curdate=%%4>current.bat

call _temp.bat

echo Current date: %curdate%

del _temp.bat>NUL
del current.bat>NUL
Avatar of ToddRod_Taylor

ASKER

SteveGTR solutions were good, I am just too limited by the Win95 platform.
Now I have a great excuse to spend more money and upgrade 15 computers and Operating Systems!
Avatar of SteveGTR
SteveGTR
Flag of United States of America image

That would be the best solution!
Windows OS
Windows OS

This topic area includes legacy versions of Windows prior to Windows 2000: Windows 3/3.1, Windows 95 and Windows 98, plus any other Windows-related versions including Windows Mobile.

129K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo