Skip to content

Commit 7accce6

Browse files
committed
Remove unused files and add Chapter 11.4 challenge solution
1 parent 7110008 commit 7accce6

File tree

19 files changed

+27
-120
lines changed

19 files changed

+27
-120
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# 11.4 Challenge: Move All Image Files To a New Directory
2+
# Solution to Challenge
3+
4+
from pathlib import Path
5+
6+
# Change this path to match the location on your computer
7+
documents_dir = (
8+
Path.home() /
9+
"python-basics-exercises" /
10+
"ch11-file-input-and-output" /
11+
"practice_files" /
12+
"documents"
13+
)
14+
15+
# Create an images/ directory in your home directory
16+
images_dir = Path.home() / "images"
17+
images_dir.mkdir(exist_ok=True)
18+
19+
# Search for image files in the documents directory and move
20+
# them to the images/ directory
21+
for path in documents_dir.rglob("*.*"):
22+
if path.suffix.lower() in [".png", ".jpg", ".gif"]:
23+
path.replace(images_dir / path.name)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Yo dad, what's up?
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1,2,3,4,5
2+
a,b,c,d,e

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy