Computing.Net > Forums > Disk Operating System > get the current folder name in var

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

get the current folder name in var

Reply to Message Icon

Name: dudecybetron
Date: February 24, 2004 at 08:01:03 Pacific
OS: win xp
CPU/Ram: 128 mb
Comment:

hi,

assume that am in the following directory.

c:\fol1\fol2\fol3

now i need a bat script that stores the current directory "fol3" in a variable.i dont want the full path.i just need the current directory in a variable.



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: February 24, 2004 at 08:57:29 Pacific
Reply:

As you are running under Windows XP the current directory is found in the CD variable so to set your own one

Set MyCurDir=%CD%


0

Response Number 2
Name: dudecybetron
Date: February 24, 2004 at 09:20:07 Pacific
Reply:

hi,

u c fellow i know that method.assume that am in c:\fol1\fol2\fol3. now if i use set mycurdir=%cd% and view that enivironment variable then what is stored in mycurdir is mycurdir=c:\fol1\fol2\fol3. i dont want this. i just want it to tell as "fol3".
(ie) mycurdir=fol3

is there a way for this?


0

Response Number 3
Name: Wengier
Date: February 24, 2004 at 12:35:05 Pacific
Reply:

Please read this:

http://computing.net/dos/wwwboard/forum/14518.html


0

Response Number 4
Name: IVO
Date: February 24, 2004 at 13:52:29 Pacific
Reply:

OK, use the following statements

Call :FOLDER %CD%
.....
.....
GoTo :EOF

:FOLDER
Set MyCurDir=%~n1
GoTo :EOF
......

where :FOLDER is an internal subroutine, :EOF the standard return label for NT-kernel batches and the labels must have the : as first character.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







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


Sponsored links

Ads by Google


Results for: get the current folder name in var

Using the Computer Name in a Batch Program www.computing.net/answers/dos/using-the-computer-name-in-a-batch-program/5560.html

How do i get the 'c' prompt in dos?? www.computing.net/answers/dos/how-do-i-get-the-c-prompt-in-dos-/10211.html

How do I get the certificate of authenticity number in dos www.computing.net/answers/dos/how-do-i-get-the-certificate-of-authenticity-number-in-dos/4017.html