1.

Solve : current folder name?

Answer»

i've got a problem again
how to get from :

c:\msdos

i need to asign current dir name to an variable in this case set a=msdos

cd command returns full adressCode: [Select]for %%A in ("%cd%") do set foldername=%%~nAC:\>type salmon.bat
Code: [Select]@echo off

cd %homepath%

echo Current Directory = %CD%

for %%A in ("%cd%") do
(
set foldername=%%~nA

echo foldername = %foldername%

echo What does the for loop do?

echo "for %%A in ("%cd%") do set foldername=%%~nA"
)


OUTPUT:


C:\> salmon.bat
Current Directory = C:\Documents and Settings\Bill Richardson
foldername = Bill Richardson

thank you!I am not sure why BillHat wrote what he did.Quote from: Salmon Trout on October 30, 2009, 11:48:01 AM

I am not sure why BillHat wrote what he did.

TO:

All Hat and No Cattle:

In Texas we always show at least part of the Output. In Canada the OUTput is not required?

MANY new users do not know how to test code.

No need to test Code by the Ghost. The Ghost code never CHECKS out.

Show and Tell is required when we are new users from Texas.

Not everybody is as dumb as you think. I believe my code is SELF explanatory.
Quote from: Salmon Trout on October 30, 2009, 12:10:35 PM
Not everybody is as dumb as you think. I believe my code is self explanatory.


There are many new users who read these boards and a little extra show and tell helps.

Not knowing and stupid are not synonymous.

"Everybody is ignorant. Only on different subjects."
Will Rogers


Discussion

No Comment Found