0

Hi,

I have a file test.txt, this file has many pathnames such as,

C:\xx\yy\zzz\bd\hello
C:\xx\yy\zzz\bd\bye
C:\xx\yy\zzz\bd\cd\de\name
C:\xx\yy\zzz\bug
C:\xx\yy\zzz\dfdfd\gt

I want to use basename or any other method to get the the last filename. At the moment in my batch script im unable to loop through the file and use basename on each path. Any other way of solving the problem can also be tried.

Thanks,
Rahul

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by cfajohnson
0

Ok I got it working, i am able to get the last file name using this code,

@echo off

rem get files into  text file

set PWD=%CD%
set WWW=%1
set WKD=%WWW%

CD %WKD%

FOR /F "tokens=*" %%a in (testing2.txt) do (

basename %%a 
)

Is it possible to send all the data to a txt now? If I try sending the stuff to the txt file at the end I just get the last pathname as each time the loop runs it erases the contents of the previous file and puts the new content. This is what im using

@echo off

rem get files into  text file

set PWD=%CD%
set WWW=%1
set WKD=%WWW%

CD %WKD%

FOR /F "tokens=*" %%a in (testing2.txt) do (

basename %%a > test.txt %%a
)

Edited by rudasi: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.