The below code does what I need it to do, but I thought that using
something like ext = os.path.splitex t(fname) and then searching ext[1]
for '.mp3' would be a much more accurate approach to solving this
problem. Could someone demonstrate how to search ext[1] for a specific
string? This script works great for deleting illegal music on user
machines ;)
Thanks!!!
import os, string
setpath = raw_input("Ente r the path: ") #This can be hard coded.
for root, dirs, files in os.walk(setpath , topdown=False):
for fname in files:
s = string.find(fna me, '.mp3')
if s >=1:
fpath = os.path.join(ro ot,fname)
os.remove(fpath )
print "Removed", fpath, "\n"
something like ext = os.path.splitex t(fname) and then searching ext[1]
for '.mp3' would be a much more accurate approach to solving this
problem. Could someone demonstrate how to search ext[1] for a specific
string? This script works great for deleting illegal music on user
machines ;)
Thanks!!!
import os, string
setpath = raw_input("Ente r the path: ") #This can be hard coded.
for root, dirs, files in os.walk(setpath , topdown=False):
for fname in files:
s = string.find(fna me, '.mp3')
if s >=1:
fpath = os.path.join(ro ot,fname)
os.remove(fpath )
print "Removed", fpath, "\n"
Comment