Hi Jacques,
You can rename files with move-item:
PS 9> new-item -type file -Name firstfile.sql
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 6/5/2008 3:58:56 PM 0.0 B firstfile.sql
PS 10> move-item firstfile.sql firstfile.processed
PS 11> dir *.pro*
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 6/5/2008 3:58:56 PM 0.0 B firstfile.processed
To get the first part of the filename:
PS 12> [io.path]::GetFileNameWithoutExtension("firstfile.sql")
firstfile
In PowerShell CTP(2) you can get the filename using the BaseName member:
PS 13> (dir .\firstfile.processed).BaseName
firstfile
---
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com Quote:
> In need to list a group of files, work on each one individually, then
> rename each one with a different suffix when I've processed it. The
> listing and looping parts I've done, but I can't find a way of
> (easily) just getting the first part of a file's name. For example, I
> need to find and process 'C:\temp\firstfile.sql', then when I've
> finished with it, rename it 'C:\temp\firstfile.processed'. I can get
> the 'C:\temp' and '.sql' into variables, but I really want the
> 'firstfile' part. Any ideas anybody?
>
> Thanks in advance
>
> Jacques
>