whats wron here?

July 9, 2009 at 23:46:26
Specs: Windows XP
I am using following code
for getting only file name by %%nx

FOR %%F %%nx IN (%EAR_SOURCE%\*.ear) do (
set fname=%%f
echo "Filename: " %fname%
set filename=%%nx
echo "Filename: " %filename%
REM md %%F
REM cd %%F
REM Step for extracting the ear content into widcell of wps
REM jar xf %%F
REM del %%F

DOS is thwoing error as
%%nx was unexpected here...

whats wrong here. I just want to get file names as abc.ear inteade of whole path
Please help me.

See More: whats wron here?

Report •

July 10, 2009 at 00:12:34
This won't happen in DOS, but to get filename.ext without path in XP:

@echo off & setLocal enableDELAYedexpansion

for /f "tokens=* delims= " %%a in ('dir/s/b/a-d d:\') do (
echo %%~NXa

If at first you don't succeed, you're about average.


Report •

July 10, 2009 at 00:27:10
Thanks for your reply but,I have to do the same for no of files not on one...:(

Report •

July 10, 2009 at 06:01:35

If you can't understand M2's hint, better you give up as the script you posted has so many mistakes that it must be fully recoded.

nx is a variable modifier NOT an internal variable and f is not declared in the For /F statement (you would code %%~nxf to catch file name and extension). More inside a For loop delayed variables must be referenced not usual ones (e.g. !filename! NOT %filename%).

The above is just the beginning , more will follow up!

Report •

Related Solutions

Ask Question