No Account Yet?

You are not logged in.

Add to: JBookmarks Add to: Facebook Add to: Windows Live Add to: Digg Add to: Del.icoi.us Add to: Reddit Add to: StumbleUpon Add to: Slashdot Add to: Netscape Add to: Furl Add to: Yahoo Add to: Blogmarks Add to: Technorati Add to: Newsvine Add to: Google Information
How to remove the last character of every filename in a directory E-mail
Programming HowTo's - Python HowTo's
Written by Allen Sanabria   
Monday, 28 April 2008 22:30
#!/usr/bin/env python
#Created by LinuxDynasty
import os, re, sys

os.chdir(sys.argv[1])
ls = os.listdir('./')
for file_o in ls:
file_n = re.sub("\w\.", ".", file_o)
os.rename(file_o, file_n)

print os.listdir("./")

To run this script you will do this.

python <script> <"directory">

python rename1.py "/home/dynasty/test"

Comments
Search RSS
Only registered users can write comments!

3.22 Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

Last Updated ( Wednesday, 14 May 2008 11:57 )