0

Hi,

Im trying to make a batch script which can go through a directory and pick all the .txt files and copy the name in a file. Ive been able to make a script which can do this in a particular folder but if there is a folder in the folder it doesnt check in that, this is what I have so far,

@echo off

rem get files into text file
 
set PD=%CD%
set WW=%1
set WD=%WW%

CD %WD%
dir /b | gawk "{print $1}" | grep \.c | sed "s/\.txt//g" > %PWD%\testing2.txt

I was thinking of using recursion to to go deeper into the folders but im not sure how to identify a folder, If I can I can use it as a kind of a stop case.

Thanks,
Rahul

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by rudasi
0

Thanks, that solves my immeadiate problem. Im using gawk to get the last column data from the file.
My file looks like this,

C:\Documents and Settings\name\test\byebye.c
C:\Documents and Settings\name\test\hello.c
C:\Documents and Settings\name\test\hey.h
C:\Documents and Settings\name\test\New Folder
C:\Documents and Settings\name\test\New Folder (2)
C:\Documents and Settings\name\test\New Folder\tesdfsftsdfds.c

using the command,

gawk "{print $NF|"

the data is split into,


Settings\name\test\byebye.c
Settings\name\test\hello.c
Settings\name\test\hey.h
Settings\name\test\New Folder
Settings\name\test\New Folder (2)
Folder\tesdfsftsdfds

What I need is to get the last file name, is it possible to get these by using gawk again or is there a way to space the data after a \, that way i can use gawk better?

Thanks.

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.