| | |
list files not containing _ab
![]() |
•
•
Join Date: Oct 2007
Posts: 18
Reputation:
Solved Threads: 0
i am using glob.glob('') function to get a list of all files from a folder. I need to get only those names which do not contain '_ab' in it. How is it possible. I understand the need for regular expressions here. i tried (?!....) . what should work here.
example :
x = glob.glob('c:\temp\*ab*')
this returns all files containing ab in it. What should i write here so that it returns only those that do not contain ab in it
Brgds,
kNish
example :
x = glob.glob('c:\temp\*ab*')
this returns all files containing ab in it. What should i write here so that it returns only those that do not contain ab in it
Brgds,
kNish
•
•
Join Date: Mar 2007
Posts: 110
Reputation:
Solved Threads: 31
•
•
•
•
i am using glob.glob('') function to get a list of all files from a folder. I need to get only those names which do not contain '_ab' in it. How is it possible. I understand the need for regular expressions here. i tried (?!....) . what should work here.
example :
x = glob.glob('c:\temp\*ab*')
this returns all files containing ab in it. What should i write here so that it returns only those that do not contain ab in it
Brgds,
kNish
Python Syntax (Toggle Plain Text)
x = [f for f in glob.glob('c:\temp\*.*') if '_ab' not in f]
•
•
Join Date: Apr 2006
Posts: 148
Reputation:
Solved Threads: 40
without glob module, just search for it
Python Syntax (Toggle Plain Text)
import os os.chdir("/somewhere") for files in os.listdir("."): if not "_ab" in files: print files
![]() |
Other Threads in the Python Forum
- Previous Thread: Sizers in Python....
- Next Thread: problems with xmlrpclib and SimpleXMLRPCServer
| Thread Tools | Search this Thread |
abrupt ansi anti apache approximation array assignment avogadro backend beginner binary bluetooth book builtin calculator character code converter countpasswordentry curved customdialog dan08 dictionaries dictionary dynamic examples exe file float format function gnu graphics gui heads homework ideas import inches input java launcher library line lines linux list lists loop mouse mysqlquery number numbers numeric output parsing path phonebook plugin pointer port prime programming progressbar projects py2exe pygame python random recursion redirect scrolledtext software statictext statistics string strings sum table terminal text textarea thread threading time tlapse trick tricks tuple tutorial twoup ubuntu unicode urllib urllib2 variable wordgame write wxpython xlib






