1.

Solve : Win/Batch: How to get the folder name from Var %1?

Answer»

Ive been cracking my HEAD the past few hours trying to figure out how to pull only the folder name from a path passed on by a varible.

%1 = C:/documents/spreadsheetNAME/filename.ext

I need only "spreadsheetNAME/filename.ext"

I can pull the filename and extension with %~nx1

But I can figure out how to pull the FOLDERNAME

Thanks
JPRockHi   
What about like this code 
Code: [SELECT]ECHO off
Set VAR=%1
for %%I in (.) do set CurrDirName=%%~nxI
for %%I in (%Var%) do Set FileName=%~nx1
echo CurrDirName\FileName = %CurrDirName%\%FileName%
pauseThanks that seemed to work.



Discussion

No Comment Found