raaj4354
asked on
Write filenames in a directory recursively to text file
Have a directory structure DIR1/
FOLDER1/fileabc.sps
CVS/abc.txt
def.entries
cfe.prop
FOLDER2/filebcd.sql
CVS/abc.txt
def.entries
cfe.prop
FOLDER3/file1def.sp
CVS/abc.txt
def.entries
cfe.prop
FOLDER4/file1cvf.ty
CVS/abc.txt
def.entries
cfe.prop
Recursively write all the filenames without extensions in to a text file
Need to ignore CVS folder and files in them... in each subdirectory.
Ignore a testfile.txt in each of the folder
Take path/to/DIR1 as parameter to the script
FOLDER1/fileabc.sps
CVS/abc.txt
def.entries
cfe.prop
FOLDER2/filebcd.sql
CVS/abc.txt
def.entries
cfe.prop
FOLDER3/file1def.sp
CVS/abc.txt
def.entries
cfe.prop
FOLDER4/file1cvf.ty
CVS/abc.txt
def.entries
cfe.prop
Recursively write all the filenames without extensions in to a text file
Need to ignore CVS folder and files in them... in each subdirectory.
Ignore a testfile.txt in each of the folder
Take path/to/DIR1 as parameter to the script
Just reread your post and have one question - by "Recursively write all the filenames without extensions in to a text file" do you mean:
1) write the list of files that don't have an extension
2) write the list of base filenames (extensions stripped)
3) something else
1) write the list of files that don't have an extension
2) write the list of base filenames (extensions stripped)
3) something else
Just noticed an omission in my code - you need to add the below line before line 17:
open OUT, ">output_file.txt" or die "could not write output: $!";
open OUT, ">output_file.txt" or die "could not write output: $!";
ASKER
I meant to write the list of base filenames (extensions stripped).
Everything works perfect... but i need to exclude a text file which is present in each subfolder. (test_text.txt). The list is showing this file name too.
Everything works perfect... but i need to exclude a text file which is present in each subfolder. (test_text.txt). The list is showing this file name too.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great and fast response.. Thanks a lot..!!
ASKER
How can i pass the directory as a parameter in which the output.txt file is stored..
I want to put the output file in a directory which i want to specify while running the command...
I want to put the output file in a directory which i want to specify while running the command...
Open in new window
If you really want to use perl then this should do it...
Open in new window