americannb
asked on
DOS variable set to current directory ONLY. Not the entire path.
This returns the current directory, but with the entire path as well. How can I get JUST the current directory?
Say this is the path: C:\WINDOWS\system32\2008-0 2-29_1157 I'm working in.
"set currentdir=%cd%" would set the currentdir variable to "C:\WINDOWS\system32\2008- 02-29_1157 " (if run from inside that directory, of course)
That's handy, but how would I set a variable to the actual current directory ONLY. I need the variable set to: "2008-02-29_1157" only.
The reason for this is that I need to use tokens of that variable to rename files located in that directory.
Say this is the path: C:\WINDOWS\system32\2008-0
"set currentdir=%cd%" would set the currentdir variable to "C:\WINDOWS\system32\2008-
That's handy, but how would I set a variable to the actual current directory ONLY. I need the variable set to: "2008-02-29_1157" only.
The reason for this is that I need to use tokens of that variable to rename files located in that directory.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Confirmed.
:-)
ASKER
All excellent answers and very helpful!
ASKER
BAM! That's the stuff, fellas! I can actually use both answers in different situations! And the different answers also helped me understand the logic which I can apply other places. Thanks a bunch!!!
WOW! That was quick! Thank you, and glad we could help in other ways too.