glob

Regular expression in Python Shutil integer range to move files

南楼画角 提交于 2020-07-16 09:42:24
问题 I have a folder with 12500 pictures. The filenames contain the numbers, so it looks like: 0.jpg 1.jpg 2.jpg 3.jpg . . .12499.jpg Now I want to move the files. Files with range 0-7999 should be copied to the first folder. Files 8000-9999 should be copied to the second folder and files with range 10000-12499 should be copied to the third folder. First, I thought I could easily use [0-7999].jpg for the first folder, [8000-9999].jpg for the second and [10000-12499].jpg for the third. However,

Using PHP ftp_get() to retrieve file with wildcard filename

吃可爱长大的小学妹 提交于 2020-07-03 03:43:11
问题 I have a file on an FTP with a dynamic filename. The schema looks something like: ABCD_2_EFGH_YYMMDD_YYMMDD_randomnumber_.TXT The dates ( YYMMDD ) reflect the previous day and current day and the randomnumber value is a count of the records in the file and varies each day. I am attempting to retrieve the file using PHP but I am having trouble using a wildcard name. Here is a sample of the code: <?php $yesterday = strtotime('-1 day', time()); $today = strtotime('-0 day', time()); $local_file =

Filter folders whose name is a timestamp - pattern matching vs. regex matching using the find utility

生来就可爱ヽ(ⅴ<●) 提交于 2020-06-27 00:46:17
问题 I am writing a generic shell script which filters out files based on given regex. My shell script: files=$(find $path -name $regex) In one of the cases (to filter), I want to filter folders inside a directory, the name of the folders are in the below format: 20161128-20:34:33:432813246 YYYYMMDD-HH:MM:SS:NS I am unable to arrive at the correct regex. I am able to get the path of the files inside the folder using the regex '*data.txt' , as I know the name of the file inside it. But it gives me

Filter folders whose name is a timestamp - pattern matching vs. regex matching using the find utility

妖精的绣舞 提交于 2020-06-27 00:44:12
问题 I am writing a generic shell script which filters out files based on given regex. My shell script: files=$(find $path -name $regex) In one of the cases (to filter), I want to filter folders inside a directory, the name of the folders are in the below format: 20161128-20:34:33:432813246 YYYYMMDD-HH:MM:SS:NS I am unable to arrive at the correct regex. I am able to get the path of the files inside the folder using the regex '*data.txt' , as I know the name of the file inside it. But it gives me

Bash arbitrary glob pattern (with spaces) in for loop

青春壹個敷衍的年華 提交于 2020-06-08 17:05:32
问题 Is there any way to reliably use an arbitrary globbing pattern that's stored in a variable? I'm having difficulty if the pattern contains both spaces and metacharacters. Here's what I mean. If I have a pattern stored in a variable without spaces, things seem to work just fine: <prompt> touch aa.{1,2,3} "a b".{1,2,3} <prompt> p="aa.?" <prompt> for f in ${p} ; do echo "|$f|" ; done |aa.1| |aa.2| |aa.3| <prompt> declare -a A=($p) ; for f in "${A[@]}" ; do echo "|$f|" ; done |aa.1| |aa.2| |aa.3|

Find files in a directory with a partial string match

允我心安 提交于 2020-05-25 05:05:11
问题 I have a directory which contains the following files: apple1.json.gz apple2.json.gz banana1.json.gz melon1.json.gz melon2.json.gz I wish to find all of the apple , banana and melon file types. From this SO answer I know that I can find by file type by: import glob, os os.chdir("/mydir") for file in glob.glob("*.json.gz"): print(file) However, in my case I can't match by file name or file type. Rather it is a partial file name match (all apple 's and so on) In this SO question, this solution

Flask send_file is sending old file instead of newest

大憨熊 提交于 2020-05-12 18:51:51
问题 I have a flask app where using one Flask route the server creates a csv file and saves it to the server. Using a generated button on the client page, another Flask route is triggered to get the most recent file, move it to a tmp folder and send that file to the user using send_file . Right now, when I run the process the first time and download the file, all works as expected. However, the second time I run the process, it serves me the old CSV instead of the newly generated one. This

Python Pandas add Filename Column CSV

戏子无情 提交于 2020-05-09 22:53:10
问题 My python code works correctly in the below example. My code combines a directory of CSV files and matches the headers. However, I want to take it a step further - how do I add a column that appends the filename of the CSV that was used? import pandas as pd import glob globbed_files = glob.glob("*.csv") #creates a list of all csv files data = [] # pd.concat takes a list of dataframes as an agrument for csv in globbed_files: frame = pd.read_csv(csv) data.append(frame) bigframe = pd.concat(data

to concatenate 4 images using np.concatenate (two vertically and two horizontally)

牧云@^-^@ 提交于 2020-04-30 06:25:24
问题 I have four images and I want to concatenate them into 1 image.I tried using concatenate function but there are multiple images and from them i need only in a batch of 4 images. Actually the images are named as 0.jpg, 1.jpg,2.jpg and 3.jpg Below is the code which contains four images and concatenates them to be one image. But i am having around 500 images in a folder and I want to group them in a pair of four based on the range like first4 then second 4 and so on. import numpy as np import

The specified glob pattern does not match any file or the default test directories are empty. - testcafe

亡梦爱人 提交于 2020-02-03 13:03:33
问题 I have started learning testcafe, as our organization wanted to invest time on R & D on getting new e2e tools for angular automation. I am trying to create an initial small test and facing the following error. I have installed the testcafe locally using the command npm install --save-dev testcafe and have created a spec file with name first-test.spec.ts import { Selector } from "testcafe"; fixture`Getting Started`.page`http://devexpress.github.io/testcafe/example`; test("My First Test", async