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

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.