1

I would like to parse the folder name and file name from passed argument. Example:

my.bat c:\windows\test.txt

I want those to be stored as follows:

FILE_NAME=test.txt
FILE_FOLDER=c:\windows\

How can I do this?

I found this but it only gets the filename.

1 Answer 1

6

You could read the help with FOR /? or How to get folder path from file path with CMD

set "FILE_NAME=%~nx1"
set "FILE_FOLDER=%~dp1"
Sign up to request clarification or add additional context in comments.

Comments

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.