summaryrefslogtreecommitdiff
path: root/Chap9PracSelectiveCopy.py
diff options
context:
space:
mode:
authormlot <petri-rush-curvy@duck.com>2025-06-06 13:40:57 -0400
committermlot <petri-rush-curvy@duck.com>2025-06-06 13:40:57 -0400
commit75a42ec54dbf721caa659ddf02c1f46fc2cb4bef (patch)
tree84be794a2481e356a7784557a6f9fb6fbf29cfdd /Chap9PracSelectiveCopy.py
initial commit for archivingHEADmain
Diffstat (limited to 'Chap9PracSelectiveCopy.py')
-rw-r--r--Chap9PracSelectiveCopy.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Chap9PracSelectiveCopy.py b/Chap9PracSelectiveCopy.py
new file mode 100644
index 0000000..9464f7e
--- /dev/null
+++ b/Chap9PracSelectiveCopy.py
@@ -0,0 +1,19 @@
+#!python
+
+# Chapter 9 Practice Selective Copy
+# Walks through a directory tree searching for pdf files and copies them to a new location
+
+import os
+import shutil
+
+def selectiveCopy(folder):
+ folder = os.path.abspath(folder)
+ for foldername, subfolders, filenames in os.walk(folder):
+ for filename in filenames:
+ if not filename.endswith('.pdf'):
+ continue
+ #shutil.copy(filename, 'c:\\pdffolder') #Commented out to protect against accidental copying
+ print('Copying ' + filename + '...') #Print only to verify working correctly
+
+selectiveCopy(r'C:\Users\username\pdffolder')
+print('Done')