Created
October 25, 2010 15:44
-
-
Save R4md4c/645159 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/python | |
from os import * | |
import sys | |
'''Function for getting the folder name from the root given''' | |
def getFolderName(root): | |
x = root.split('/') | |
return x[-1] | |
'''Recurse or walk to every directory i put root, dirs and files variables because the walk function | |
returns a 3 tuple each contains the current folder, the directories in the current folder and | |
files inside the current folder. repectively''' | |
for root, dirs, files in walk(sys.argv[1], topdown=True): | |
x = root | |
'''I did a try and catch block because the remove function returns an OSError exception if the file to | |
be removed is not found so i made that to skip that error''' | |
try: | |
remove(x+'/'+getFolderName(x)+'.exe') | |
except OSError: | |
pass | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice, can you comment so as i can understand it :D