Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions file_length_script.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import os

#Runs on Windows only

print 'Welcome! this program will find files with pathnames that are too long'.center(80, '+')

print 'Welcome! this program will find files with pathnames that are too long'.center(75, '+')
outputfile = open(raw_input('Name output file: '),'w')
filename = raw_input('Name output file: ')

os.chdir(str(raw_input('Which directory? ')))
if filename[-4:] != '.txt': filename += '.txt'

outputfile = open(filename,'w')# opens file matching name, otherwise creates file if not found


dir = str(raw_input('Which directory? '))
if dir[0] == 'J':
serverpath = 11
elif dir[0] == 'K':
serverpath = 8
else :
serverpath = 0

os.chdir(dir)

count = 0

Expand All @@ -17,10 +31,11 @@

x = (root +'\\' + i )[2:] #removes ./ from filename and assigns full filepath to directory

if len(x) > 255:
if (len(x)+serverpath) > 255:
#print 'Files written: ' + str(count +1)
print len(x)
outputfile.write(x + '\n')
#print (dir + '\\' + x + '\n')
#print len(x)
outputfile.write(dir + '\\' + x + '\n')
count +=1


Expand Down