Code: Select all
@echo off
for /f "tokens=1-13* delims=\" %%a in ("%cd%") do (
@echo %%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m
)
there must be a more elegant way of doing this. ideas?
Moderator: DosItHelp
Code: Select all
@echo off
for /f "tokens=1-13* delims=\" %%a in ("%cd%") do (
@echo %%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m
)
Code: Select all
echo "%cd:\=" "%"
Code: Select all
@echo off
for %%a in (one two three) echo %%a
Code: Select all
for %%n in (My name is john) do echo %%n
Code: Select all
My
name
is
john
Code: Select all
for %%n in ("My name is john") do echo %%n
"My name is john"
Code: Select all
for %%n in ("My name is john") do echo %%~n
My name is john
Code: Select all
echo %cd:\=" "%
C:" "Documents and Settings" "All Users" "Desktop
"C:" "Documents and Settings" "All Users" "Desktop"
Code: Select all
::Current directory: C:\Documents and Settings\All Users\Desktop
for %%n in ("%cd:\=" "%") do echo %%~n
C:
Documents and Settings
All Users
Desktop
foxidrive wrote:Open a cmd prompt in a deep nested folder and use this command (which is inside the for command above).
That should show you how the for command is used in this case - because this is what is replaced in the parentheses when it runs.Code: Select all
echo "%cd:\=" "%"
it is similar to this usage of the for command:Code: Select all
@echo off
for %%a in (one two three) echo %%a
Fawers wrote:Damn, aGerman. That was genius! I would never had thought of that.
As said before, brilliant.