Expand wildcards in shells of Windows using the dir or the Get-ChildItem command
Project description
win_wildcard
Expand wildcards in shells of Windows using the dir or the Get-ChildItem command.
Sample
import sys
from win_wildcard import expand_windows_wildcard
files = []
for a in sys.argv[1:]:
r = expand_windows_wildcard(a)
files.extend(r)
print('\n'.join(files))
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.
- PowerShell allow to use wildcard while copying file but cmd don't allow , why?
- Globbing patterns in windows command prompt/ powershell
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file win_wildcard-0.5.0.tar.gz
.
File metadata
- Download URL: win_wildcard-0.5.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6f089ae029e79ac49c8fd41ceb1a473bf29be31bd99cb7707615f44ad0462df |
|
MD5 | 1893381dcf0c87e732d62aa2bf7f733c |
|
BLAKE2b-256 | c0a32b1c59ac6d336f90188292429e6891ae737314ce113df66cebacddf7efc9 |