Chris Rebert wrote:
> On Mon, Aug 9, 2010 at 3:19 AM, Peter Otten <__pete...@web.de> wrote:
>> Warning: I don't remember how Windows handles this, but unix will happily
>> perform os.rename("alpha/alpha.txt", "beta/beta.txt") and overwrite
>> beta/beta.txt with alpha/alpha.txt.
>>
>> I'd rather m
On Mon, Aug 9, 2010 at 3:19 AM, Peter Otten <__pete...@web.de> wrote:
> Chris Rebert wrote:
>
>> Hence (untested):
>> from os import listdir, rename
>> from os.path import isdir, join
>> directory = raw_input("input file directory")
>> s = raw_input("search for name")
>> r = raw_input("replace name
MRAB wrote:
from os.path import isdir, join
Have a look at the imports, Dave. :-)
Oops. I should have noticed that it was a function call, not a
method. And there's no built-in called join(). I just usually avoid
using this kind of alias, unless performance requires.
thanks for ke
Dave Angel wrote:
blur959 wrote:
On Aug 9, 6:01 pm, Chris Rebert wrote:
os.rename() takes paths that are absolute (or possibly relative to the
cwd), not paths that are relative to some arbitrary directory (as
returned by os.listdir()).
Also, never name a variable "file"; it shadows the name
blur959 wrote:
On Aug 9, 6:01 pm, Chris Rebert wrote:
os.rename() takes paths that are absolute (or possibly relative to the
cwd), not paths that are relative to some arbitrary directory (as
returned by os.listdir()).
Also, never name a variable "file"; it shadows the name of the built-in t
On Aug 9, 6:01 pm, Chris Rebert wrote:
> On Mon, Aug 9, 2010 at 2:44 AM, blur959 wrote:
> > Hi, all, I am working on a simple program that renames files based on
> > the directory the user gives, the names the user searched and the
> > names the user want to replace. However, I encounter some pro
Chris Rebert wrote:
> Hence (untested):
> from os import listdir, rename
> from os.path import isdir, join
> directory = raw_input("input file directory")
> s = raw_input("search for name")
> r = raw_input("replace name")
>
> for filename in listdir(directory):
> path = join(directory, filena
blur959 wrote:
> Hi, all, I am working on a simple program that renames files based on
> the directory the user gives, the names the user searched and the
> names the user want to replace. However, I encounter some problems.
> When I try running the script, when it gets to the os.rename part,
> the
On Mon, Aug 9, 2010 at 3:14 PM, blur959 wrote:
> Hi, all, I am working on a simple program that renames files based on
> the directory the user gives, the names the user searched and the
> names the user want to replace. However, I encounter some problems.
> When I try running the script, when it
On Mon, Aug 9, 2010 at 2:44 AM, blur959 wrote:
> Hi, all, I am working on a simple program that renames files based on
> the directory the user gives, the names the user searched and the
> names the user want to replace. However, I encounter some problems.
> When I try running the script, when it
10 matches
Mail list logo