Here's a quick example of reading a directory and filtering for file extension.
[D:/TECS/projects/09/Square]
% cat d:/tmp/test.py
import os
dir_name = '.' # ( should use argument from command line)
for file_name in os.listdir(dir_name):
if file_name[-5:] == '.jack':
out_name = file_name[:-5] + '.vm'
print(file_name, '->', out_name)
[D:/TECS/projects/09/Square]
% d:/tmp/test.py
Main.jack -> Main.vm
Square.jack -> Square.vm
SquareGame.jack -> SquareGame.vm
[D:/TECS/projects/09/Square]
% ls
Main.jack OS\ Square.hack Square.lst SquareGame.jack
Main.vm Square.asm Square.jack Square.vm SquareGame.vm
[D:/TECS/projects/09/Square]
%
(For code that is intended to be cross-platform portable you should use the os.path functions that know about OS specific file naming conventions.)
--Mark