glob

PHP Filesystem Pagination

How does one paginate a large listing of files within a folder? I can't see any functions in the PHP documentation that mention any way to specify an 'offset'. Both glob() and scandir() simply return all the files in the folder, and I'm afraid that won't be a good idea for a huge directory. Is there any better way of doing this than si...

Recursively add files by pattern

How do I recursively add files by a pattern (or glob) located in different directories? For example, I'd like to add A/B/C/foo.java and D/E/F/bar.java (and several other java files) with one command: git add '*.java' Unfortunately, that doesn't work as expected. ...

zsh for loop exclusion

This is somewhat of a simple question, but for the life of me, I cannot figure out how to exclude something from a zsh for loop. For instance, let's say we have this: for $package in /home/user/settings/* do # do stuff done Let's say that in /home/user/settings/, there is a particular directory ("os") that I want to ignore. Logica...

Issue in creating Zip file using glob.glob

Hi, I am creating a Zip file from a folder (and subfolders). it works fine and creates a new .zip file also but I am having an issue while using glob.glob. It is reading all files from the desired folder (source folder) and writing to the new zip file but the problem is that it is, however, adding subdirectories, but not adding files fo...

Glob() filesearch, question

Hi, a little question. I have this code, which is works perfect for files, but If am trying search on a directory name, the result is blank. How I can fix that? <?php function listdirs($dir,$search) { static $alldirs = array(); $dirs = glob($dir."*"); foreach ($dirs as $d){ if(is_file($d)){ $filename = pa...

Test whether a glob has any matches in bash

If I want to check for the existance of a single file, I can test for it using test -e filename or [ -e filename ]. Supposing I have a glob and I want to know whether any files exist whose names match the glob. The glob can match 0 files (in which case I need to do nothing), or it can match 1 or more files (in which case I need to do so...

what does *~ mean in glob?

What is the meaning of *~ in glob syntax? For example, in a sample .hgignore file: syntax: glob .DS_Store *.swp *~.nib what is difference between a *~.nib and *.nib ? Thanks ...

R: Brace expansion in Sys.glob()

Is it possible to have R's Sys.glob() function expand braces? What I mean is a pattern similar to /home/foo/{a,b}/bar.txt should find files /home/foo/a/bar.txt and /home/foo/b/bar.txt should they both exist. By default R does not expand the braces. Brace expansion is possible in glob(3) with the GLOB_BRACE flag. I am guessing R is just...

Iterate over specific files in a directory

I need to get all images that begin with "t_" using glob. What pattern should I use to do this? //get any image files that begin with "t_" -- (t_image.jpg) not (image.jpg) $images = glob("" . $dir . "*.jpg"); foreach($images as $image) { echo $image; } ...

PHP pagination using glob to retrieve images

I'm trying to retrieve images from a folder using glob() and i want it to be paginated so it only displays 3 images per page. From digging around on the internet and here on S.O. i've got the code below. The problem is that it only pulls three images from the directory and when i click on the next page it shows the same 3 images. What ...

zsh filename globbling/substitution

I am trying to create my first zsh completion script, in this case for the command netcfg. Lame as it may sound I have stuck on the first hurdle, disclaimer, I know how to do this crudely, however I seek the "ZSH WAY" to do this. I need to list the files in /etc/networking but only the files, not the directory component, so I do the f...

tcl "switch -glob" does not match with variable

Hi, I encountered this issue on both Solaris and Linux, with tcl version 8.3/8.4 please see the following code: #!/usr/bin/tclsh set pattern "this is * and *" set str "this is tcl and c++" switch -glob $str { $pattern { puts "matched pattern" } "this is * and *" { puts "matched plain text" } default { puts "mat...

Ignore files in Mercurial using Glob syntax

I'm using Mercurial and I have a following structure: files test demo.jpg video.flv video.doc sport demo2.jpg picture.jpg text.txt demo3.jpg demofile3.doc I want to make a glob filter that only ignore all "jpg" files in all directory that are children of "files" directory I tried with ...

Globbing with python rpm module?

The following code uses the rpm module to query the version of an installed package. What I would like to do is to query a set of packages specified by a glob, for example searching for "python*" rather than "python". Is this possible using the rpm module? 1 #!/usr/bin/python 2 3 import rpm 4 5 ts = rpm.TransactionSet() ...

perl: iterate over a typeglob

Given a typeglob, how can I find which types are actually defined? In my application, we user PERL as a simple configuration format. I'd like to require() the user config file, then be able to see which variables are defined, as well as what types they are. Code: (questionable quality advisory) #!/usr/bin/env perl use strict; use war...

Mixing ordered lists, links and variables in PHP/HTML

I'm taking a break from Project Euler to learn some PHP/HTML for kicks and giggles, and I found a page of simple exercises. So, on my 'site,' I want to have an ordered list of links to pages of each of the exercises, but I decided to do it in a dynamic manner as opposed to hard coding each item as I do the exercise. Unfortunately, the p...

Globbing/pathname expansion with colon as separator

How can I convert a string containing glob characters such as /var/lib/gems/*/bin into a colon-separated string of filenames (i.e. PATH compatible) matching the pattern? i.e. echo /var/lib/gems/*/bin will return /var/lib/gems/1.8/bin /var/lib/gems/1.9.1/bin I want /var/lib/gems/1.8/bin:/var/lib/gems/1.9.1/bin instead. The obv...

php glob() not returning all files

Hello there. I searched this site and found a very useful snippet of code that i've been able to use. $counter = 0; foreach (glob("images/gallery/photo_gallery/resized/*.jpg") as $pathToThumb) { $filename = basename($pathToThumb); $pathToLarge = 'images/gallery/photo_gallery/' . $filename; echo ('<...

Using Glob to set a filename into a variable?

I am simply trying to set a variable to a filename, I know the start and end of the filename, but part of the filename is date stamped and is therefore variable. However this simple test gives me an error <?php $apps = (glob('/var/www/vhosts/smartphonesoft.com/httpdocs/fred/epf/file*.tbz'); echo $apps; ?> PHP Parse error: syntax...

PHP glob contents of all files in a directory removing unique BUT create new 500 line files.

The files in the directory are named 1.txt, 2.txt, 3.txt etc.... The snippet below enters that directory, opens all the *,txt files reading them, removes the dupes and creates one file with all the unique contents. (names in this case). $files = glob($dirname."/*.txt"); //matches all text files $lines = array(); foreach($files a...