Do I have to write a script for this or is there some other workaround/module that can do this? For example can I use gci *.ptx with tree or some other command? This is my first post so I apologize if I am not being clear or if my question is super basic!
1 Answer
The below command is an example.
Get-ChildItem . file.* -Recurse
This will search the current directory recursively for files starting with file.
To generalize the format should be
Get-ChildItem path_to_look_for file_name_with_wildcar*s -option
The * as you expect will do the wildcard match, technically called file name expansion or globbing.
Also note that Get-ChildItem has following aliases :
gci
ls
dir
So
dir path_to_look_for file_name_with_wildcar*s -option
has the same effect
4 Comments
Clint
I noticed that the following also works: Get-ChildItem -Recurse file
sjsam
@Clint : It should. Here you just change order of arguments. By default Get-ChildItem looks in the current directory. So if you don't explixitly give the path, it looks in the directory from where you execute the command.
Clint
Thank you @sjsam for your detailed answer!
sjsam
@Clint : You may accept is as a token of encouragement :D
Get-ChildItem -Recurse