To get the list of directory files in an out outfile without extension - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

To get the list of directory files in an out outfile without extension

kraghavendkraghavend Posts: 2Member
Hello Sir

I am started writing the pythan program by reading tutorials and requesting experts help. I tried with below code but did not work for me.

If the folder has say FILE1.CBL, FILE2.CBL, FILE4.TXT and FILE3.CBL.

I need the output in the OUTPUT FILE as below

FILE1
FILE2
FILE3

import os
import glob
import fileinput
Path = os.getcwd()
count = 0
os.chdir(Path)
filenames = glob.glob("*.cbl")
cobolfile = open('outlib.txt', 'w')
cobolfile.writelines(filenames.split('.cbl'))
cobolfile.close()
raw_input("Press Enter to Exit")

Thank you
Raghu
Sign In or Register to comment.