Re: change extensions

2005-04-11 Thread Peter Hansen
Tim Roberts wrote: "Bob Then" <[EMAIL PROTECTED]> wrote: how can i change all files from one extension to another within a direcory? In Windows, the quickest way is: os.system( "rename *.old *.new" ) I have a vague memory that this won't work on all versions of Windows... possibly it isn't supp

Re: change extensions

2005-04-07 Thread Tim Roberts
"Bob Then" <[EMAIL PROTECTED]> wrote: >how can i change all files from one extension to another within a direcory? In Windows, the quickest way is: os.system( "rename *.old *.new" ) -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listi

Re: change extensions

2005-04-05 Thread Bill Mill
On Apr 5, 2005 10:43 AM, Jeffrey Maitland <[EMAIL PROTECTED]> wrote: > That approach works, but so does this one. > > import os, glob > > input_file_list = glob.glob('*.txt') > for in_file in input_file_list: > name = in_file.split('.') > os.rename(in_file, str(name[0]) + '.' + 'text')) >

RE: change extensions

2005-04-05 Thread Jeffrey Maitland
ith the period but if you use a variable (string) for the extension then you can't -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Peter Hansen Sent: Tuesday, April 05, 2005 10:35 AM To: python-list@python.org Subject: Re: change extensions Bob Then

Re: change extensions

2005-04-05 Thread Peter Hansen
Bob Then wrote: how can i change all files from one extension to another within a direcory? Using Jason Orendorff's path.py module: # change all .py files in '.' to extension .new from path import path for f in path('.').files(): if f.endswith('.py'): f.rename(f.splitext()[0] + '.new')

Re: change extensions

2005-04-04 Thread David Wilson
Bob Then wrote: > how can i change all files from one extension to another within a direcory? This should work: import os def change_exts(suffix, new_suffix, dir_name): for name in os.listdir(dir_name): if name.endswith(suffix): old_pathname = os.path.join(dir_name, name)

Re: change extensions

2005-04-04 Thread Gerhard Häring
Bob Then wrote: how can i change all files from one extension to another within a direcory? Using os.listdir, os.path.split and os.rename. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list