On Mon, Aug 9, 2010 at 2:44 AM, blur959 blur...@hotmail.com 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
On Mon, Aug 9, 2010 at 3:14 PM, blur959 blur...@hotmail.com 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
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,
there
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, filename) #paste the
On Aug 9, 6:01 pm, Chris Rebert c...@rebertia.com wrote:
On Mon, Aug 9, 2010 at 2:44 AM, blur959 blur...@hotmail.com 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.
blur959 wrote:
On Aug 9, 6:01 pm, Chris Rebert c...@rebertia.com wrote:
snip
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
Dave Angel wrote:
blur959 wrote:
On Aug 9, 6:01 pm, Chris Rebert c...@rebertia.com wrote:
snip
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;
MRAB wrote:
snip
from os.path import isdir, join
snip
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.
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)
for filename in
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 modify the
10 matches
Mail list logo