1.

Solve : Strip part of string?

Answer»

Hi,

I have a BATCH file that runs when a NEW file is created in a certain directory. it captures the new file in variable %1 i then write this to a text file eg:

New file Received E:\FTP\test\(newfile)

This is then emailed off.

My question is how can i strip whats written to the text file, as i only want it to write:


New file Received (newfile)

Dropping the path.

Any IDEAS,

Thanks in advance,
Slash
you can try this for a start


set arg=%1
For %%I in (%arg%) do (
set filename=%%~nxI
echo %filename%
)

Thanks for the reply, i've ended up doing this:

SET STRING=%1
SET STRING=%STRING:C:\FTP\test\=%
SET STRING=%STRING:.ext=%

ECHO Batch %STRING% > c:\test\test.txt

%1 contained (C:\FTP\test\new1.ext)

after the strip it contained (new1)

This was what i was after, guess it was similar to what you suggested.

Thanks,
SlashGuys! ECHO.Batch [highlight]%~n1[/highlight]> c:\test\test.txt [/B]



Discussion

No Comment Found