Hi folks,
is there a way to negate a glob() pattern?
What I want is to get a tree structure, e.g. all .php files *and* all
directories.
How would I start here?
--
Freundliche Grüße,
Franz Marksteiner 2 2686
Hi,
The find command can search within a directory tree:
$dir = dirname(__FILE_ _);
$cmd = 'find ' . escapeshellarg( $dir) . ' -name "*.php" ' .
'-o -type d 2>&1';
exec($cmd, $output, $exitCode);
if ($exitCode != 0) {
throw new Exception("Comm and \"$cmd\" failed with " .
"exit code $exitCode: " . join("\n", $output));
}
echo "Found " . count($output) . " entries.<br>\n" ;
As for glob, you can just call it multiple times: once with *.php and
once with the GLOB_ONLYDIR flag.
You could also use opendir/readdir.
On Mar 16, 5:31 pm, "Franz Marksteiner" <franzmarkstei. ..@gmail.com>
wrote:
Hi folks,
is there a way to negate a glob() pattern?
What I want is to get a tree structure, e.g. all .php files *and* all
directories.
How would I start here?
--
Freundliche Grüße,
Franz Marksteiner
petersprc wrote:
As for glob, you can just call it multiple times: once with *.php and
once with the GLOB_ONLYDIR flag.
Yeah, I guess that makes sense.
You could also use opendir/readdir.
The thing is that glob seems to be way easier with the pattern
functionality.
In the past I did use opendir.
What would you prefer?
On Mar 16, 5:31 pm, "Franz Marksteiner" <franzmarkstei. ..@gmail.com>
wrote:
>Hi folks,
is there a way to negate a glob() pattern? What I want is to get a tree structure, e.g. all .php files *and* all directories. How would I start here?
-- Freundliche Grüße, Franz Marksteiner
--
Freundliche Grüße,
Franz Marksteiner This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Georgy Pruss |
last post by:
On Windows XP glob.glob doesn't work properly for files without extensions.
E.g. C:\Temp contains 4 files: 2 with extensions, 2 without.
C:\Temp>dir /b *
aaaaa.aaa
bbbbb.bbb
ccccc
ddddd
C:\Temp>dir /b *.
|
by: Eric |
last post by:
Pythonistas,
I seem at a loss for a List Comprehension syntax that will do what I want.
I have a list of string position spans:
>>> breaks
the first pair representing: someString
|
by: Elbert Lev |
last post by:
#Here is the script
#Python 2.3 on W2K
import glob
name = glob.glob(u"./*.mp3")
print type(name)
name = glob.glob(u"*.mp3")
print type(name)
|
by: Python Dunce |
last post by:
I've run into an issue with glob and matching filenames with brackets ''
in them. The problem comes when I'm using part of such a filename as the
path I'm passing to glob. Here's a trimmed down dumb example. Let's say I
have a directory with the following files in it.
foo.par2
foo.vol0+1.par2
foo.vol1+1.par2
zzz .par2
zzz .vol0+1.par2
|
by: Hitesh |
last post by:
import string
import os
f = open ("c:\\servername.txt", 'r')
linelist = f.read()
lineLog = string.split(linelist, '\n')
lineLog = lineLog
#print lineLog
for l in lineLog:
| |
by: J |
last post by:
Greetings Group-
I'm trying to put together a pattern matching script that scans a
directory tree for tif images contained in similar folder names, but
running into a NewB problem already. Is it the way I'm trying to join
multiple paths? Any help would be greatly appericated. Thanks, J!
import glob, sys, os
topdir = sys.argv
|
by: mark.bergman |
last post by:
I am porting from Digital Unix to Linux (RHEL 4), and am seeing a
difference in the return value of glob().
Given a non-existant directory "/tmp/a", and the following line of
code:
result = glob("/tmp/a", GLOB_ERR, NULL, &globInfo);
- result is set to GLOB_NOMATCH on both platforms.
However, if the first parameter is changed to "/tmp/a/*", i.e.
searching for files within the directory, the return value on Digital
Unix is still...
|
by: billiejoex |
last post by:
os.listdir(path) return a list of file names independently if the path-
argument used is absolute or relative:
'/home/user'
glob.glob, instead, return file names only if given path is relative:
'/home/user/Desktop
|
by: jo3c |
last post by:
hi everyone happy new year!
im a newbie to python
i have a question
by using linecache and glob
how do i read a specific line from a file in a batch and then insert
it into database?
because it doesn't work! i can't use glob wildcard with linecache
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |