Skip to content

Instantly share code, notes, and snippets.

@R4md4c
Created October 25, 2010 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save R4md4c/645159 to your computer and use it in GitHub Desktop.
Save R4md4c/645159 to your computer and use it in GitHub Desktop.
#/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
@emad-elsaid
Copy link

nice, can you comment so as i can understand it :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment