Re: Rename files with specific file extension
From: Curtis Fray (curtis.fray_at_Xbssmail.nhs.uk)
Date: 01/31/05
- Next message: McKirahan: "Re: environment variable"
- Previous message: Torgeir Bakken \(MVP\): "Re: Printer Admin Object"
- In reply to: Steve Fulton: "Re: Rename files with specific file extension"
- Next in thread: Steve Fulton: "Re: Rename files with specific file extension"
- Reply: Steve Fulton: "Re: Rename files with specific file extension"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 31 Jan 2005 15:08:29 -0000
Hi again,
Sorry there is one addition that would be helpful. If a pst file is open
during the running of this, it errors. How can I update the script so it
continues when it encounters an error?
Thanks,
Curtis.
"Steve Fulton" <cerberus40@hotmail.com> wrote in message
news:opslgwygsmboz00o@msnews.microsoft.com...
> Curtis Fray wrote:
>
>> Could anyone tell me how I can write a script which will scan all files
>> in
>> all folders on a drive and rename anything with a *.pst extension to a
>> *.ps1
>> extension?
>
> Dim Drive, Root, Pst
>
> Drive = "A" 'your drive spec here
>
> Set Root = CreateObject("Scripting.FileSystemObject"). _
> GetDrive(Drive).RootFolder
>
> Set Pst = New RegExp
> With Pst
> .Pattern = "\.pst$"
> .IgnoreCase = True
> .Global = False
> .Multiline = False
> End With
>
> Call Rename(Root, Pst)
>
> Sub Rename(Folder, RegExp)
> Dim SubFolder, File
>
> For Each File in Folder.Files
> If RegExp.Test(File.Name) Then
> File.Name = RegExp.Replace(File.Name, ".ps1")
> End If
> Next
>
> For Each SubFolder In Folder.SubFolders
> Call Rename(SubFolder, RegExp)
> Next
> End Sub
>
>> Curtis.
>
> Please use a proper separator (two dashes and a space "-- ") before
> your signature.
>
> --
> Steve
>
> Those who dream by day are cognizant of many things which escape those
> who dream only by night. -Edgar Allan Poe
- Next message: McKirahan: "Re: environment variable"
- Previous message: Torgeir Bakken \(MVP\): "Re: Printer Admin Object"
- In reply to: Steve Fulton: "Re: Rename files with specific file extension"
- Next in thread: Steve Fulton: "Re: Rename files with specific file extension"
- Reply: Steve Fulton: "Re: Rename files with specific file extension"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|