Skip to content

Commit 675c704

Browse files
author
Elizabeth England
committed
Merge remote-tracking branch 'refs/remotes/ehanson8/master'
2 parents 169af2d + 55ff4d2 commit 675c704

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

collapseDirectories.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
import csv
44
from datetime import datetime
55

6-
filePath = raw_input('Enter file path (C:/Test/): ')
6+
filePath = raw_input('Enter file path (C:/Test/): ')+'/'
77

88
f=csv.writer(open('moveLog'+datetime.now().strftime('%Y-%m-%d %H.%M.%S')+'.csv','wb'))
99
f.writerow(['oldLocation']+['newLocation'])
10+
print filePath
1011
for root, dirs, files in os.walk(filePath, topdown=True):
1112
for name in files:
12-
if os.path.join(root, name).count('/') > 9:
13+
if os.path.join(root, name).count('/') > 8:
1314
level0 = root.index('/')+1
1415
level1 = root.index('/', level0)+1
1516
level2 = root.index('/', level1)+1
@@ -18,10 +19,9 @@
1819
level5 = root.index('/', level4)+1
1920
level6 = root.index('/', level5)+1
2021
level7 = root.index('/', level6)+1
21-
level8 = root.index('/', level7)+1
2222
oldLocation = os.path.join(root, name)
2323
print oldLocation
24-
newLocation = root[:level8]+name
24+
newLocation = root[:level7]+name
2525
print newLocation
2626
shutil.move(oldLocation, newLocation)
2727
f.writerow([oldLocation]+[newLocation])

0 commit comments

Comments
 (0)