0

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!

4
  • 3
    Get-ChildItem -Recurse Commented May 5, 2016 at 16:49
  • Thank you! works like a charm. Commented May 5, 2016 at 17:03
  • This is very basic. It doesn't hurt to actually try yourself before asking. You used more time registering and writing this question than you did searching on Google. :-) Commented May 5, 2016 at 21:36
  • Actually not true I did try doing it myself using other methods but I am a beginner - I spent over two weeks trying to figure it out! Commented May 6, 2016 at 13:56

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

4 Comments

I noticed that the following also works: Get-ChildItem -Recurse file
@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.
Thank you @sjsam for your detailed answer!
@Clint : You may accept is as a token of encouragement :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.