Renaming of files in OS directory

blur959 blur959 at hotmail.com
Sun Aug 8 09:43:52 EDT 2010


On Aug 8, 9:13 pm, Thomas Jollans <tho... at jollans.com> wrote:
> On 08/08/2010 02:35 PM, blur959 wrote:
>
> > Sorry, This is my first time using the os commands in python, Ok,
> > firstly, I entered "C:\" inside raw_input and stored it inside
> > fileroot. When i print repr(fileroot), my result was '"C:\\"' . And
> > when I run os.listdir with fileroot, I got that error. I typed my
> > os.listdir code like this: os.listdir(fileroot)
>
> > I attached my code for reference, thanks again!
>
> Okay, maybe you've already understood the problem now, but in case you
> haven't:
> '"C:\\"' is no valid file name. The quotes ("") are part of what you're
> passing to the OS here, which you don't want. Just enter the file name
> without quotes. (or, if you really want quoting for some reason, you
> could manually strip the quotes, or use the shlex module.
>
>
>
> > import os, glob
>
> > def fileDirectory():
> >     # Ask user for file directory input
> >     fileroot = raw_input("Input")
> >     print repr(fileroot)
>
> >     #Returns a list with all the files inside the file root
> > directory( The error occurs here )
> >     os.listdir(fileroot)
>
> > fileDirectory()
>
>

okay i got it already thanks alot man! Appreciate it!



More information about the Python-list mailing list