Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DOS Batch

Status
Not open for further replies.

gonzilla

Programmer
Apr 10, 2001
125
US
Hi,

Yes, I know that this is an old topic, but I have a batch file that I am trying to alter and can't quite figure something out. I need to have something that will give me the current working directory...ie.

If the cwd is...
c:\Temp\Directory1\Directory2

I run the batch, I want to be able to set a variable to just 'Directory2'

set VAR1 = ????

The reason I need this is because I need to make this directory in a new location and case matters (won't go into why). So, I need to mkdir something like...

mkdir t:\Jobs\%VAR1%

and get...

t:\Jobs\Directory2

Is this possible using batch files?

Thanks for the help.

-Tyler

 
Ignore this - I figured out a way to do it...

set UDIR=%~dp1

for /F "tokens=3* delims=\" %%i in ('echo %UDIR%') do set PDIR=t:\jobs\%%i
 
Simpler way:

Batch File maked.bat:
=====================
if %!==! goto onerror
md t:\jobs\%1
goto end
:eek:nerror
@echo Enter maked and directory name
:end
==================================
To run just type

maked directory2

Actually the only line you really need is:
md t:\jobs\%1 GlennA
MIS






 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top