tos-kamiya / win_wildcard

Expand wildcards in shells of Windows using the dir or the Get-ChildItem command.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

win_wildcard

Expand wildcards in shells of Windows using the dir or the Get-ChildItem command.

Sample

See samples/expand_args.py for the source code of the expand_args.py.

Run in PowerShell

Run in cmd.exe

Motivation

Python has a glob module that supports posix-spec wildcards, so it is possible to create scripts with wildcards available. However, for the reasons described below, glob's wildcard is not the same as expected on the Windows command line.

The Windows shell leaves wildcard expansion to the command, so there is no standard way to expand wildcards.

Some wildcards of cmd.exe are undocumented.

There have been reports of user confusion due to wildcard specifications varying from command to command.

I thought it would be appropriate to provide a function that calls the dir command or Get-ChildItem command and uses the result of expanding the wildcard.

Such wildcard expansion would allow the user to run the dir or Get-ChildItem command to see what files are specified before executing the script.

About

Expand wildcards in shells of Windows using the dir or the Get-ChildItem command.

License:The Unlicense


Languages

Language:Python 100.0%