View Single Post
Old 08-29-2007   #5 (permalink)
powersheller


 
 

Re: get-child item question from a newbie

On Aug 29, 8:19 am, "Brandon Shell" <tshell.m...@xxxxxx> wrote:
Quote:

> I read your question as you just want to run some specific EXE's in
> subfolders... if that is this case. These will help.
>
> If your intent is to run a specific list of exe's in each subfolder you and
> do this.
> $include = "somecommand.exe","somecommand2.exe"
> get-childitems c:\somedir -include $include -recursive | %{invoke-express
> $_.fullname}
>
> Info: Get-Childitem has an include parameter that allows you match a string
> or an array of string. In this case an array of strings that contains
> filename of the EXE(s)
>
> If you just want to run all of them
> get-childitems c:\somedir -filter *.exe -recursive | %{invoke-express
> $_.fullname}
>
> Info: Get-Childitem has a Filte parameter that lets you filter the result
> set by a specific string. In this case *.exe
>
> NOTE: You dont have to be in the folder of the EXE to execute. It is just
> like cmd prompt in that aspect. As long as you qualify the path you are
> good.
>
> For more info
> PS> get-help Get-Childitem -full
>
> <powershel...@xxxxxx> wrote in message
>
> news:1188345673.374024.311640@xxxxxx
>
>
>
Quote:

> > Ok, this is my first day working with powershell. I'm sure this
> > question couldn't be easier, but I can't seem to figure it out.
>
Quote:

> > All I want to do is run a script which would accomplish the following.
>
Quote:

> > run a command in each sub directory
>
Quote:

> > here is what I would do at a command line.
> > c:\somedir> cd\subdir
> > c:\somedir\subdir>
> > c:\somedir\subdir>somecommand.exe
> > c:\somedir\subdir>cd..
> > c:\somedir\>cd\subdir2
> > c:\somedir\subdir2>somecommand.exe
>
Quote:

> > etc. it's probably very easy, but I can't figure out how to pass the
> > get-child item result to set-location
>
Quote:

> > any suggestions would be greatly appreciated.
>
Quote:

> > ej- Hide quoted text -
>
> - Show quoted text -
First of all, I want to thank everyone that has offered suggestions.
I'm still a bit stumped on this.
as far as I can tell the solutions don't address the fact that I just
want to step one level deep from the current dir and run a specific
command (in this case it's actually a script that must be run from
current dir, I can't just run it from a different dir with the correct
path.) and then I need to go back up one dir and then back down into
the next dir and run the same command.
I don't think I need -recurse because I don't want to go deeper than
the one level.
I know this is probably really easy, I just don't see it. I'm spinning
my wheels here on something I know shouldn't take more than a minute
or two.

thanks in advance.

My System SpecsSystem Spec