Created
March 4, 2024 13:49
-
-
Save JEuler/6a5836da17e48148c10226b565c3725a to your computer and use it in GitHub Desktop.
Extract .jpg files from folders in some current folder.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import shutil | |
def extract_jpg_files(root_folder): | |
for root, dirs, files in os.walk(root_folder): | |
for file in files: | |
if file.endswith('.jpg'): | |
source_path = os.path.join(root, file) | |
destination_path = os.path.join(root_folder, file) | |
shutil.move(source_path, destination_path) | |
print(f'Moved: {source_path} -> {destination_path}') | |
# Use the current working directory as the root folder | |
root_folder_path = os.getcwd() | |
extract_jpg_files(root_folder_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment