-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselectiveCopy.py
More file actions
37 lines (20 loc) · 824 Bytes
/
selectiveCopy.py
File metadata and controls
37 lines (20 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 3 10:57:33 2021
@author: martsc1
"""
# selective copy
import os,shutil
# Write a program that walks through a folder tree and searches for files with a certain file extension (such as .pdf or .jpg).
# Copy these files from whatever location they are in to a new folder.
print('Enter folder tree directory:')
folderTree = input()
print('Enter file extension you want to copy:')
fileExtenstion = input()
print('Enter copy destination directory:')
destinationFolder = input()
for folderName, subfolders, filenames in os.walk(folderTree):
for file in filenames:
if fileExtenstion in file:
print('Copied file '+file)
shutil.copy(folderName+'/'+file, destinationFolder+'/'+file)