Computing.Net > Forums > Disk Operating System > a variable cant be identified.

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

a variable cant be identified.

Reply to Message Icon

Original Message
Name: Najib (by Nael_Najib)
Date: April 3, 2005 at 11:35:47 Pacific
Subject: a variable cant be identified.
OS: Windows 2000 professional
CPU/Ram: 512MB
Comment:

Could you please tell me whats wrong with this batch file ... it doesnt accept the variable (Najib) though its identified...I want it to create a directory by the year and then get into it and create another folder with the month.
This is the script...
(Note: i have a utility that recognizes the cut command since i have no idea how to do it in DOS)

#@echo off
Set ToDay=%3
Set Nael=Date /T | cut -c 5-6
Set Najib=Date /T | cut -c 11-15
If not "%ToDay%"=="" GoTo EXEC
For /F "Tokens=2 Delims= " %%a in ('Date /T') Do Set Today=%%a
:EXEC
pause

if not exist c:\batch_files\ammar\%Najib% GoTo CREATES
For /F "Tokens=1-4 Delims=/ " %%a in ('Date /T') Do @echo md %%d > mdyear.bat
call mdyear.bat
del c:\batch_files\ammar\mdyear.bat
:CREATES
pause

For /F "Tokens=1-4 Delims=/ " %%a in ('Date /T') Do @echo cd %%d > cdyear.bat
call cdyear.bat
del C:\batch_files\ammar\cdyear.bat

if not exist c:\batch_files\ammar\%Najib%\%Nael% GoTo CREATE
For /F "Tokens=1-4 Delims=/ " %%a in ('Date /T') Do @echo md %%b > c:\batch_files\ammar\%Najib%\mdmo.bat
call c:\batch_files\ammar\%Najib%\mdmo.bat
del c:\batch_files\ammar\%Najib%\mdmo.bat
:CREATE

Set ToDay=


thanks for your cooperation.


Aladimi


Report Offensive Message For Removal


Response Number 1
Name: Mechanix2Go
Date: April 3, 2005 at 12:02:03 Pacific
Reply:

Well,

For starters, this:

#@echo off

won't turn off echo.

Next, it would help to know what "cut" is doing.

And this:

For /F "Tokens=1-4 Delims=/

won't do much in DOS.


M2

If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 2
Name: rogerashley
Date: April 3, 2005 at 13:26:13 Pacific
Reply:

M2GO why does it not work in DOS Standalone ??

DO NOT BAN THE MESSENGER


Report Offensive Follow Up For Removal

Response Number 3
Name: dtech10
Date: April 4, 2005 at 09:31:28 Pacific
Reply:

Hi Najib
I take it from your code that your in the wrong forum, maybe you should move to the Programming forum, if you want to use Win2000 command prompt as this is for DOS stanalone and not anything that runs from a command prompt in Windows.
From your code I think your just creating a directory for the Year and one inside it for
the month, and then moving to the month directory.
I do not see why you need the Today variable at all to do this.
Some people do not like people who answer any thing in this forum that is not Stand ALone DOS.


Report Offensive Follow Up For Removal

Response Number 4
Name: Mechanix2Go
Date: April 4, 2005 at 09:54:56 Pacific
Reply:

RA,

AFAIK, DOS does not use 'for /f' or tokens.


M2

If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 5
Name: rogerashley
Date: April 4, 2005 at 11:54:17 Pacific
Reply:

Thanks M2GO but from the "dtech10" response I figured it was not worth bothering about.

DO NOT BAN THE MESSENGER


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home



Results for: a variable cant be identified.

Redirecting text file to a variable?
    Summary: too bad you cant store a file thats big at all in a variable eh? 40000bytes would be entirely impossible, and even 128 bytes would be pushing it. - W0rm...
www.computing.net/answers/dos/redirecting-text-file-to-a-variable/3566.html

Need Leading Zeroes in a Variable.
    Summary: I'd like to thank Mr. Pignataro for his kind assistance with a few issues I've asked about. I am still dealing with the desire to insert leading zeroes into a variable, which could contain any value f...
www.computing.net/answers/dos/need-leading-zeroes-in-a-variable/13612.html

copy a file to a variable
    Summary: Hi! I want to copy a file from a server to the desktop. Trouble is i want to do it for lots of ppl so i set a variable using USERNAME so it looks something like: Can't do backslashes so the'll be repr...
www.computing.net/answers/dos/copy-a-file-to-a-variable/12678.html






Which MP3 player do you have?

iPod/iPhone
Zune
Something Else
None


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge
Poll History






Data Recovery Software