glob

How to search (case-sensitive) for files using Java glob pattern?

限于喜欢 提交于 2019-12-23 17:09:42
问题 I am checking the getPathMatcher method of FileSystem class. The documentation of the method says: For both the glob and regex syntaxes, the matching details, such as whether the matching is case sensitive, are implementation-dependent and therefore not specified. I tested this and came to know that by default it is case-insensitive. How to make it case-sensitive? I am using JDK7u25 on Windows7. 回答1: No, it is not case-insensitive by default. As the doc says, case sensitivity is

Inverse glob - reverse engineer a wildcard string from file names

我怕爱的太早我们不能终老 提交于 2019-12-23 16:25:06
问题 I want to generate a wildcard string from a pair of file names. Kind of an inverse-glob. Example: file1 = 'some foo file.txt' file2 = 'some bar file.txt' assert 'some * file.txt' == inverse_glob(file1, file2) Use difflib perhaps? Has this been solved already? Application is a large set of data files with similar names. I want to compare each pair of file names and then present a comparison of pairs of files with "similar" names. I figure if I can do a reverse-glob on each pair, then those

gulp.src() include files but ignore all folders

做~自己de王妃 提交于 2019-12-23 14:19:53
问题 There is certainly such a simple answer to this that I can't find anyone that's asked it before: What globbing pattern to include all the files in a folder but ignore ALL subfolders? gulp.src('*') includes all files and folders. I just want the files and would rather not have to exclude the folders individually. 回答1: If you want to include .dotFiles as well then try gulp.src(['folder/*.*', 'folder/.*']) 回答2: Just use the nodir option when you call gulp.src . This will actually test the files

gulp.src() include files but ignore all folders

有些话、适合烂在心里 提交于 2019-12-23 14:19:01
问题 There is certainly such a simple answer to this that I can't find anyone that's asked it before: What globbing pattern to include all the files in a folder but ignore ALL subfolders? gulp.src('*') includes all files and folders. I just want the files and would rather not have to exclude the folders individually. 回答1: If you want to include .dotFiles as well then try gulp.src(['folder/*.*', 'folder/.*']) 回答2: Just use the nodir option when you call gulp.src . This will actually test the files

Use multiple file extensions for glob to find files

社会主义新天地 提交于 2019-12-23 13:15:23
问题 I am using glob to list out all my python files in the home directory by this line of code. I want to find all .json files too along with py files, but I couldn't found any to scan for multiple file types in one line code. for file in glob.glob('/home/mohan/**/*.py', recursive=True): print(file) 回答1: You could use os.walk, which looks in subdirectories as well. import os for root, dirs, files in os.walk("path/to/directory"): for file in files: if file.endswith((".py", ".json")): # The arg can

Python 3.6 glob include hidden files and folders

久未见 提交于 2019-12-23 09:37:23
问题 I try to loop over all files matching a certain extension, including those inside hidden folders. So far I haven't found a way to do this with iglob. This works for all folder except those starting with a dot: import glob for filename in glob.iglob('/path/**/*.ext', recursive=True): print(filename) I have tried to add the dot as an optional character to no avail. I'd really like to use glob instead of residing to os.walk 回答1: I had this same issue and wished glob.glob had an optional

Opencv: Why does the file size change when I read and write an image without making any changes?

耗尽温柔 提交于 2019-12-22 23:54:34
问题 I have a list of (.TIFF) files which I am renaming and saving in the same format. I am using cv2 module to do this. import cv2 import os import glob os.chdir('C:/99_Temp/') for file in glob.glob("*.tiff"): f = os.path.splitext(file) time_val = f[0][:2] a1 = cv2.imread(file) cv2.imwrite(time_val+'.tiff',a1) Why are the file sizes reduced from the original TIFF file? I haven't done any processing and visually the images look the same. But I am wondering, why the difference? 回答1: There could be

php glob number range in filename

a 夏天 提交于 2019-12-22 22:47:27
问题 I've checked two other answers but can't seem to match a range of numbers in file name I need to match 1.jpg to anything upto 99.jpg (no leading zeros and no prefix or suffix), just plain digits.jpg glob("$dir/{1..99}.jpg", GLOB_BRACE); and I've also tried: glob("$dir/{" . implode(",", range(1, 99)) . "}.jpg", GLOB_BRACE); The following matches only 1.jpg to 9.jpg but not 10,11 etc glob("$dir/[0-9].jpg", GLOB_BRACE); The following matches nothing: glob("$dir/[0-9]+.jpg", GLOB_BRACE); I've

how can I get this readdir code sample to search other directories

蓝咒 提交于 2019-12-22 20:12:05
问题 I am currently working with a code example that initially is designed to take an argument, then search for that argument in the current directory, I've tried to make it search another directory (/dev/shm to exact) by replacing the "." with "/dev/shm" but the code turns up nothing when i search for something* (notice the wildcard). The wild card search works fine in the current directory so I do not think it is the wild card that is the problem, If someone could help me out though I would

Regular expression, glob, Python

耗尽温柔 提交于 2019-12-22 17:55:21
问题 I have a folder, contains many files. There is a group contains pc_0.txt,pc_1.txt,...,pc_699.txt. I want to select all files beetween pc_200 - > to pc_699.txt How? for filename in glob.glob("pc*.txt"): global_list.append(filename) 回答1: For this specific case, glob already supports what you need (see fnmatch docs for glob wildcards). You can just do: for filename in glob.glob("pc[23456]??.txt"): If you need to be extra specific that the two trailing characters are numbers (some files might