Re: Tutoring help automating with python

Roel Schroeven <[email protected]>
Newsgroups gmane.comp.python.tutor
Message-ID <[email protected]>
Op 26/07/2023 om 22:17 schreef Fatima Mehak:
> #*Traceback (most recent call last):
> #  File "/home/student-03-61dc276e6247/./fix_image.py", line 23, in <module>
> #    for file in os.listdir(srcdir):
> #FileNotFoundError: [Errno 2] No such file or directory: '../input/'
Hi,

Others have already answered why '../input/' is not found. Once that is 
solved, though, you're going to have the next issue: if I'm not 
mistaken, Image.open(srcfile) will not find srcfile. That's because 
os.listdir() returns the names of the files, with no reference to the 
directory they're in.

One solution is to do something like this:

     for file in os.listdir(srcdir):
         resize_rename_rotate(os.path.join(srcdir, file), targetdir)

Regards,
Roel

-- 
"You can fool some of the people all the time, and all of the people some
of the time, but you cannot fool all of the people all of the time."
         -- Abraham Lincoln
"You can fool too many of the people too much of the time."
         -- James Thurber
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.