get filename from absolute path in batch program

hey im writing batch program for the first time and i have almost finished it the only problem is that i want to extract basename from absolute path
for eg :
if my first argument is c:\abcd\xyz\temp.txt then i want only temp.txt in variable.

and how do i extract some part from string for eg abcd.txt if i want only abcd i can use cut -d"." -f1 in unix. how to do this in windows ??

Hi Zedex,

you should first send this absolute path as a arguement to a batch script.

sample script is onlyfilename.bat and it contents are as is..

-----------------
echo Just the file name is %~nx1
..
..
..
----------------------

I'm too late here but still would be a reference for others who are looking for it :slight_smile:

--ilan