Skip to content

Instantly share code, notes, and snippets.

@jakekara
Last active July 11, 2020 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakekara/38b4d9fd2eee6af066010bcaa72349ec to your computer and use it in GitHub Desktop.
Save jakekara/38b4d9fd2eee6af066010bcaa72349ec to your computer and use it in GitHub Desktop.
Find files with matching patterns using wolframscript
#!/usr/bin/env wolframscript
(* Recursively dump a list of files that match a given pattern *)
(* Very basic script to play with Wolfram outside of Notebooks *)
(* Jake Kara <jake@jakekara.com *)
(* Example usage: *)
(* ./glob.wl "*.txt" *)
If[
Length[$ScriptCommandLine] < 2,
Print["Usage: " <> $ScriptCommandLine[[1]] <> " PATTERN"]; Exit[1]
]
pattern = $ScriptCommandLine[[2]]
PrintLine[str_] := Print[str]
Map[PrintLine,FileNames[pattern,"./", Infinity]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment