Skip to content

Commit 4952249

Browse files
author
Ishaq Khan
committed
finished files section
1 parent f6a2dfd commit 4952249

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Diff for: walkatree.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#walking a dir tree
2+
import os
3+
import shutil
4+
theWalk = os.walk('C:\\Users\\ikhan\\Documents\\JavascriptTutorial')
5+
for folderName, subFolders, filenames in theWalk:
6+
print('folder is' + folderName)
7+
print('the subfolder ' + str(subFolders))
8+
print('and the filename ' + str(filenames))
9+
#loop through items
10+
for subFolder in subFolders:
11+
if 'extension' in subFolder:
12+
#os.rmdir(subFolder) #removes item
13+
14+
for filename in filenames:
15+
if filename.endswith('.py'):
16+
shutil.copy(os.join(folderName, file), os.join(folderName, filename + 'back-up')) #makes a copy
17+
18+

0 commit comments

Comments
 (0)