Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Directory path EOF
#3
Thanks Larz
I had already tried that, the reason it didn't work for me was that I had the path wrong didn't realise that windows truncated username.
So changed the path and ran the program again with the following result
C:\Users\anybl\Python_Progs\shapes>image.py
[<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=4032x3024 at 0x3C10950>]
What I am after is just a list of the images in a folder i.e
images_0.jpg
images_1.jpg
images_2.jpg
images_3.jpg

I have used this code.
import pathlib

# define the path
currentDirectory = pathlib.Path('.')

for currentFile in currentDirectory.iterdir():  
    print(currentFile)
Which gave me this.
C:\Users\anybl\Python_Progs\shapes>image.py
cat.png
image.py
Shapes.py
Shapes2_Pic.png
Shapes_Pic.png
star.png
Which would be fine if it only gave me the images and not the .py extensions.
Reply


Messages In This Thread
Directory path EOF - by Graham - Nov-27-2018, 11:33 PM
RE: Directory path EOF - by Larz60+ - Nov-28-2018, 12:35 AM
RE: Directory path EOF - by Graham - Nov-28-2018, 08:18 AM
RE: Directory path EOF - by Larz60+ - Nov-28-2018, 08:30 AM
RE: Directory path EOF - by Graham - Nov-28-2018, 09:17 AM
RE: Directory path EOF - by Larz60+ - Nov-28-2018, 09:25 AM
RE: Directory path EOF - by Graham - Nov-28-2018, 09:47 AM
RE: Directory path EOF - by Larz60+ - Nov-28-2018, 03:00 PM
RE: Directory path EOF - by Graham - Nov-28-2018, 10:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  working directory if using windows path-variable chitarup 2 871 Nov-28-2023, 11:36 PM
Last Post: chitarup
  create a default path with idle to a specific directory greybill 0 935 Apr-23-2023, 04:32 AM
Last Post: greybill
  WebDriverException: Message: 'PATH TO CHROME DRIVER' executable needs to be in PATH Led_Zeppelin 1 2,311 Sep-09-2021, 01:25 PM
Last Post: Yoriz
  In put path and directory Led_Zeppelin 1 2,552 Apr-23-2021, 03:25 AM
Last Post: Larz60+
  How do I set the path to my module one directory below my python 3.7.3 program? deac33 1 2,097 Jul-30-2019, 04:13 AM
Last Post: Larz60+
  Directory path gahhon 3 3,061 Mar-03-2019, 11:39 PM
Last Post: DeaD_EyE
  .pth file does not show up in sys.path when configuring path. arjunsingh2908 2 5,930 Jul-03-2018, 11:16 AM
Last Post: arjunsingh2908

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020