glob

Perl - A way to get only the first (.txt) filename from another directory without loading them all?

佐手、 提交于 2019-12-11 18:54:33
问题 I have a directory that holds ~5000 2,400 sized .txt files. I just want one filename from that directory; order does not matter. The file will be processed and deleted. This is not the scripts working directory. The intention is: to open that file, read it, do some stuff, unlink it and then loop to the next file. My crude attempt does not check for only .txt files and also has to get all ~5000 filenames just for one filename. I am also possibly calling too many modules? The Verify_Empty sub

PHP GLOB more than one pattern at a time

心已入冬 提交于 2019-12-11 17:52:38
问题 code: $matches = glob("$searchword*.txt", GLOB_BRACE) ; that works, but i also have $secondword, so i read How to define multiple patterns in php glob() so i tried $matches = glob("{$searchword},{$secondword}*.txt", GLOB_BRACE) ; $matches = glob("{$searchword,$secondword}*.txt", GLOB_BRACE) ; $matches = glob("{$searchword*.txt},{$secondword*.txt}", GLOB_BRACE) ; $matches = glob("$searchword*.txt", GLOB_BRACE) && ("$secondword*.txt", GLOB_BRACE); $matches = (glob("$searchword*.txt", GLOB_BRACE

PHP finding file where post INCLUDES portion of filename

限于喜欢 提交于 2019-12-11 17:28:51
问题 I am posting a variable to a PHP process in an attempt to find a file in a directory. The problem is the filename is much longer than what the user will submit. They will only submit a voyage number that looks like this: 222INE Whereas the filename will look like this: CMDU-YMUNICORN-222INE-23082016.txt So I need PHP to be able to look into the directory, find the file that has the matching voyage number, and confirm it's existence (I really need to be able to download said file, but that'll

Build Directory Exclusion List Programmatically for Find Command (Bash)

随声附和 提交于 2019-12-11 17:28:15
问题 I have an array of directories to exlude from the result of my find command, something like EXCLUDE=("foo" "bar") . I can run this from the interactive terminal like so: find . -name 'hvr.yml' -not -path "foo/*" -not -path "bar/*" And so i tried to build the argument up like this: getServersToCheck() { # Build command arguments to exclude given dirs local exclude_command="-not -path" local excount=${#EXCLUDE[@]} for ((i=0;i<excount;i++)); do EXCLUDE[i]="${exclude_command} ${EXCLUDE[i]}/*"

how to get all the files from multiple folders with the same names

半腔热情 提交于 2019-12-11 15:49:22
问题 There are many folders with the same name on the drive (don't ask how it happened). I want to get the names of all the files from the folders with the same name. The main challenge is the I don't know all the locations of these folders. D: folder1/abc/folder_needed/ folder2/qwe/qwe2/folder_needed/ ... folder_zxc/x/y/folder_needed/ I try to do smth like this: for name in glob.glob('*/folder_needed/*'): print name 回答1: Here's one possible method: import os hits = [] for dirpath, dirnames,

How do I turn datefinder output into a list?

帅比萌擦擦* 提交于 2019-12-11 15:27:58
问题 So this has been answered here: making output of datefinder into list Unfortunately my rep is too low so I can't comment to get clarity on why it's not functioning as expected. I want to take filename strings and turn them into a list of dates so that I can then use them as a fill for the date column. All of the filenames include event dates, but they are not on the sheets themselves. The format is: CompanyNameEventLocationDDMMYYYY.xlsx import glob import datefinder #get all Excel files

Glob files and sort by filemtime and into months

自闭症网瘾萝莉.ら 提交于 2019-12-11 15:16:17
问题 Yes, I know this is ugly code :) And it doesn't work. I'm globbing all the .php files in a directory and then sorting them by file timestamp, and then I want to echo the file names into each month. But how do I fix this loop so the echoed output of each month is correct? The files by $path are sorted by date, but the $link_title is the same for all files in all months, so I don't see that the $paths are getting arranged by month. foreach (glob("*.php") as $path) { $files[$path] = filemtime(

Running glob() from an included script returns empty array

我们两清 提交于 2019-12-11 14:15:19
问题 Perhaps I'm over-looking some minor error somewhere, however I have spent 20 minutes staring at this and re-reading the PHP manual, which is far too long for me to spend on a single line of code. I am writing a WordPress plugin which is implemented as a class. In my plugin I have the following line: $choices = glob(dirname(__FILE__)."/images/*.{gif,jpg,jpeg,png}", GLOB_BRACE); Clearly I want $choices to be an array containing every image in the "images" folder, relative to the included file.

trailing asterisks on windows JVM command-line args are globbed in cygwin bash shell

梦想的初衷 提交于 2019-12-11 11:11:13
问题 UPDATE: this problem occurs when running JVM-based command line tools in a cygwin bash shell. Although I originally thought this was related to Scala, it's specific to the Windows JVM. It might be the result of breaking changes in MSDN libraries, see comments below. I'm writing a scala utility script that takes a literal java classpath entry and analyzes it. I'd like my main method to be able to receive command line arguments with a trailing asterisk, e.g, "/*", but there seems to be no way

java nio negate a glob pattern

筅森魡賤 提交于 2019-12-11 09:42:40
问题 fileSystem.getPathMatcher("glob:${pattern}").matches(path.getFileName())} I want to match everything that DOES NOT match "ts.*". What's the syntax for that for a glob in java? (Before anyone suggests I use regex instead, I am required to use a glob) 回答1: If we look at the official documentation we find that the only way how to negate something is by using bracket expressions. If the character after the [ is a ! then it is used for negation so [!a-c] matches any character except "a", "b", or