View Single Post
Old 07-11-2008   #8 (permalink)
Michael Gao


 
 

Re: File name prefix?

Hi,
I think you can get the folder name like this:
((gci C:\scripts\test.txt).directory).name

"scripts " should be return.

MG

"Megan" <Megan@xxxxxx> wrote in message
news:633932BE-E406-4BD9-AFAA-0669DD730F6D@xxxxxx
Quote:

> Hi,
>
> I'm new to powershell and having a similar problem where I'm trying to
> rename the file with folder name as the prefix.
>
> eg. C:\scripts\test.txt
> becomes
> C:\scripts\scripts_test.txt
>
> I can get it to loop through and rename, but can't find a way to return
> the
> folder name to append to the existing name?
>
> Any advice is appreciated. Thanks
>
> "Jacques" wrote:
>
Quote:

>> Shay
>>
>> That does it! Many thanks.
>>
>> Jacques
>>
>>
>>
My System SpecsSystem Spec