2

Have a script that gets the current path and grabs the last two directories in that path

for /F "tokens=5,6 delims=\" %%a in ("%0") do (
    ECHO %%a
    ECHO %%b
)

output is:

2017
Customer 91 Folder

I need the output to look like:

2017
Customer\ 91\ Folder

I am using this variable to envoke and rsync script in linux which needs the directory path spaces escaped.

Thanks!

1 Answer 1

3
setlocal enableDelayedExpansion
for /F "tokens=5,6 delims=\" %%a in ("%0") do (
    ECHO %%a
    set "second_line=%%b"
    ECHO !second_line: =\ !
)
Sign up to request clarification or add additional context in comments.

1 Comment

Um, I'd suggest !second_line: =\ !...doesn't work with metavariables!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.