| | |
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 |
address advanced aliased anydbm bash beginner bits calling casino changecolor clear command conversion convert corners count csv cturtle cursor curves definedlines dictionary digital dynamic dynamically events examples excel external file float format frange function gui handling hints homework i/o iframe import input java line linux list lists loan loop matching mouse multiple number numbers obexftp output parsing path port prime programming projects py py2exe pygame python random rational raw_input recursion recursive return scrolledtext searchingfile signal singleton skinning string strings tails terminal text threading time tkinter tlapse tooltip tuple tutorial type ubuntu unicode urllib urllib2 valueerror variable web-scrape whileloop word wxpython






