Is there a standard (preferably Apache Commons or similarly non-viral) library for doing "glob" type matches in Java? When I had to do similar in Perl once, I just changed all the "." to "\.", the "*" to ".*" and the "?" to "." and that sort of thing, but I'm wondering if somebody has done the work for me.
Similar question: http://stac...
Is there a smooth way to glob in C or C++ in Windows?
E.g., myprogram.exe *.txt sends my program an ARGV list that has...ARGV[1]=*.txt in it.
I would like to be able to have a function (let's call it readglob) that takes a string and returns a vector of strings, each containing a filename.
This way, if I have files a.txt b.txt c.txt i...
I'm not necessarily looking for a better way to do this, rather an explanations of the output would greatly be appreciated. Recently, a senior programmer asked me why his code worked but only for one instance. What I came to find out was that it worked every other occurrence. Here is my example:
#!/usr/bin/perl -w
use strict;
my @li...
Here is my current code (that i am very proud of for my first attempt at php)
<?php
$files = glob("/jobops/*.txt");
$indexcount = count($files);
sort($files);
print("<br>"+$indexcount+"<br>");
foreach ($files as &$file)
{
print("<a href=\"$file\">$file</a><br>");
}
?>
the problem is glob again works fine in the root directory (whe...
Is there any guarantee that the array of filenames returned from a glob (e.g. <*>) will be sorted?
I can't find that sorting is mentioned one way or the other in the documentation, but it seems to be the case in every directory I've tried it on.
I'm talking about using this syntax:
@files = <*>;
If I need the files to be sorted, wou...
This question is a spin-off from this one. Some history: when I first learned Perl, I pretty much always used glob rather than opendir + readdir because I found it easier. Then later various posts and readings suggested that glob was bad, and so now I pretty much always use readdir.
After thinking over this recent question I realized th...
This answer indicates that glob can sometimes return 'filenames' that don't exist.
@deck = glob "{A,K,Q,J,10,9,8,7,6,5,4,3,2}{\x{2660},\x{2665},\x{2666},\x{2663}}";
However, that code returns an empty list when I run it.
What am I missing?
This run was from the command prompt using -e, on Windows XP, with ActiveState Perl version ...
I understand that the wildcard * (by itself) will expand in such a way that it means "all non-hidden files in the current folder" with hidden files being those prefixed by a period.
There are two use cases that I would think are useful, but I don't know how to properly do:
How can you glob for... "All files in the current folder, incl...
I am a beginner to Perl syntax and have a basic wildcard question. I am looking for an expression that would allow me to retrieve all of the following files.
/home/test-1.txt
/home/test-2.txt
/home/test-3.txt
I am just interested in the actual wildcard expression, not the file I/O.
...
Whenever glob pattern match fails, it stops the whole job. For instance,
$ mv *.jpg *.png folder1 && blahblah
mv: cannot stat `*.jpg': No such file or directory
*.png isn't moved to folder1 and blahblah is not run.
And the script below works only for the case when both .[A-z]* and * succeed.
#!/bin/bash
cd $1
du -sk .[A-z]* *| sort...
How do I define a minimum and maximum (possibly unbounded) number of times a certain pattern should repeat itself? I know there's ? and *, with which I could build the pattern by repeating it a certain amount of times, but I know there's a special notation for it using {}, I just can't remember how it is.
...
I'm trying to create a script to convert from $GIT_DIR/info/exclude to .gitignore files. I'd like to put the .gitignore files as close to the pattern target as possible, meaning that a glob like /a/b/*/*.c should be put in /a/b/.gitignore. To do this accurately, I need something which can return the longest substring from the start which...
I'm writing a script to batch resize images. Originally I was applying an operation for file in $(ls $1), but I would like to be able to use globbing, so I'm looking at something more like for file in $(echo $1). The problem is that dotglob may or may not be enabled, so echo * could return hidden files (notably, .DS_Store), which cause c...
Hi,
I need to load images from 2 different folders, each thumbnail has its associated large version (same name, different folder).
I have 3 files in the large pics folder and 3 files in the thumbs folder and I'm getting 9 links! Each thumbnail gets repeated 3 times or x times the quantity of pics in the main folder
This is the code:
<?...
I know I can do this
glob('/dir/somewhere/*.zip');
but is there a way to return all files that are not ZIPs?
Or should I just iterate through and filter off ones with that extension?
Thanks
...
I want to grab a list of all the files under a particular directory. Dir.glob works great, but there doesn't seem to be a way to limit results to just files (excluding directories).
Heres's what I have right now:
files = Dir.glob('my_dir/**/*').reject { |f| File.directory?(f) }
Is there a more elegant way to accomplish this?
...
I was just looking at Can someone tell me how to create an array of directory contents?. Unsurprisingly, file globs were offered as an answer. What surprised me was that the post recommended using glob() rather than <*>.
I use use <*> because that is what I learned a long time ago and have never thought about it. Which is not a good ...
How would I list the first 5 files or directories in directory sorted alphabetically with PHP?
...
I am writing a custom file system crawler, which gets passed millions of globs to process through sys.stdin. I'm finding that when running the script, its memory usage increases massively over time and the whole thing crawls practically to a halt. I've written a minimal case below which shows the problem. Am I doing something wrong, or h...
This is what I have:
Glob(os.path.join('src','*.c'))
but I want to search the subfolders of src. Something like this would work:
Glob(os.path.join('src','*.c'))
Glob(os.path.join('src','*','*.c'))
Glob(os.path.join('src','*','*','*.c'))
Glob(os.path.join('src','*','*','*','*.c'))
But this is obviously limited and clunky.
...