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
  • 57,267
  • 35
  • 174
  • 180

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
  • 78,592
  • 17
  • 171
  • 225