Allow file globbing patterns in file/folder operations

Description

Allow * and ? to be used in file system operations to match any number of characters or a single character in a file or folder path.

rm *.txt
touch step?.cfm

Abstract the logic to build a regex string based on the wildcard into a library. Create a method that accepts:

  1. The file pattern

  2. A closure to be executed for each match

The method will loop over everything in that directory and run the closure against every match. Something like this:

edit: Look at the Globbing patterns of Grunt for some other approaches. Note, Grunt matches file paths outside the task and simply passes an array of the matched paths in.
http://gruntjs.com/configuring-tasks#globbing-patterns

Activity

Show:
Brad Wood
March 23, 2017, 10:27 PM
Edited

Globbing solution used was a variation of the file globber already built for the box.json ignores syntax which is similar to npm's standard file globbing.

  • Use * to match any directory or file name

  • Use ** to match recursively across directories

  • use ? to match a single character

Globber supports a fluent API that allows you to get an array of matching file paths back or to execute a closure against each.

Returns an array of all text files recursively below the myFolder directory whose name end with bar.

Apply a closure to all markdown files in a directory.

Brad Wood
April 14, 2017, 4:36 AM

These commands updated to allow for file globbing:

  • dir

  • delete

  • touch

  • mv

  • cp

  • cat

  • edit

Fixed

Assignee

Brad Wood

Reporter

Brad Wood

Labels

None

Affects versions

None

Fix versions

Time tracking

0m

Time remaining

4h

Priority

Major