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.

Community
  • 1
  • 1
Caner
  • 53,818
  • 35
  • 164
  • 173

1 Answers1

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"
Community
  • 1
  • 1
jeb
  • 74,839
  • 15
  • 166
  • 215