Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Moving files from one directory to another based on the file name contains specified string by using vbscript

1,895 views
Skip to first unread message

Sarvesh

unread,
Jan 23, 2009, 9:29:18 AM1/23/09
to
Hi,

I am having different kind of files need to move from one drive to
another based on the file name contains specified string by using
vbscript. For example, i need to move the file that the filename
contains string "mylog". Please help me to write vbscript to do this
job.

Thanks,
Sarvesh

Reventlov

unread,
Jan 25, 2009, 5:07:54 PM1/25/09
to
Il giorno Fri, 23 Jan 2009 06:29:18 -0800 (PST), Sarvesh <sarves...@gmail.com> ha
scritto:

This asks dos to write a file with the pathnames of all the files you are looking for
(maybe).

drive="c:\"
cmd = "dir "& trim(drive) & "*mylog* /s/b "
tmp = "c:\data\pathnames.txt"
Set WshShell = CreateObject("WScript.Shell")
WSHShell.Run "%comspec% /c " & cmd & " >" & tmp, 0, True

--
Giovanni Cenati (Bergamo, Italy)
Write to "Reventlov" at katamail com
http://digilander.libero.it/Cenati (Esempi e programmi in VbScript)
--

Sarvesh

unread,
Jan 29, 2009, 10:01:08 AM1/29/09
to
On Jan 26, 3:07 am, no...@no.void (Reventlov) wrote:
> Il giorno Fri, 23 Jan 2009 06:29:18 -0800 (PST), Sarvesh <sarveswar...@gmail.com> ha

> scritto:
>
> >Hi,
>
> >I am having different kind of files need to move from one drive to
> >another based on the file name contains specified string by using
> >vbscript. For example, i need to move the file that the filename
> >contains string "mylog". Please help me to write vbscript to do this
> >job.
>
> This asks dos to write a file with the pathnames of all the files you are looking for
> (maybe).
>
> drive="c:\"
> cmd = "dir "& trim(drive) & "*mylog* /s/b "  
>  tmp = "c:\data\pathnames.txt"
>  Set WshShell = CreateObject("WScript.Shell")
>  WSHShell.Run "%comspec% /c " & cmd & " >" & tmp, 0, True
>
> --
> Giovanni Cenati (Bergamo, Italy)
> Write to "Reventlov" at katamail comhttp://digilander.libero.it/Cenati(Esempi e programmi in VbScript)
> --

Hi,

The above mentioned code is not moving any files. It is just creating
pathnames.txt file. I need to move the files that those filenames
contains string "mylog".

Please help me to get the appropriate code.

Thanks in Advance.

Regards,
Sarvesh

Pegasus (MVP)

unread,
Jan 29, 2009, 10:53:41 AM1/29/09
to

"Sarvesh" <sarves...@gmail.com> wrote in message
news:b6d16742-0962-4466...@41g2000yqf.googlegroups.com...

You need to think about your requirements in more detail and post the
following information:
- Where are your files kept? In a single folder? In a directory tree?
- Where do you want to move them to? To the root of another partition? To a
folder on that partition? If so, what name? Do you wish to rebuild the
source directory tree on the target partition?
- What should happen if a file of the same name already exists on the target
partition?
- Can you show us the (partial) script solution you have developed so far?


Sarvesh

unread,
Feb 3, 2009, 7:23:04 AM2/3/09
to
On Jan 29, 8:53 pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
> "Sarvesh" <sarveswar...@gmail.com> wrote in message

Hi,

I am having the below code to move the files from one drive(c:) to
another(d:).

Option Explicit

Dim oFS, oFile, sFile

Set oFS = WScript.CreateObject("Scripting.FileSystemObject")

Const sSourceFdr = "C:\test1\"
Const sDestFdr = "D:\test2\"
Const nDays = 10

For Each oFile In oFS.GetFolder(sSourceFdr).Files
On Error Resume Next
If DateDiff("d", oFile.DateLastModified, Now) > nDays Then
oFS.MoveFile oFile.Path, sDestFdr
End If
On Error Goto 0
Next
Set oFS = Nothing
WScript.Quit

I need cut and paste the files those filename's contains "mylog" .

Thanks,
Sarvesh

Pegasus (MVP)

unread,
Feb 3, 2009, 8:41:06 AM2/3/09
to

"Sarvesh" <sarves...@gmail.com> wrote in message
news:f11127d0-3ab3-431a...@s20g2000yqh.googlegroups.com...

Hi,

Option Explicit

Dim oFS, oFile, sFile

Thanks,
Sarvesh

==================

You can introduce an overall "if" condition like so:
if instr(1, oFile.Name, "mylog", 1) > 0 then
{do your file move}
end if


Rahul

unread,
Feb 11, 2009, 3:59:01 AM2/11/09
to
Hi Sarvesh,

Try the below script...

Dim sOriginFolder, sDestinationFolder, sFile, oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
sOriginFolder = "D:\Documents\P2P Dev\BoA_H2H\XML\"
sDestinationFolder = "D:\Documents\P2P Dev\BoA_H2H\XML\TrasnferXML\"
For Each sFile In oFSO.GetFolder(sOriginFolder).Files
If instr(1, sFile.Name, ".xml", 1) > 0 then
oFSO.MoveFile sFile, sDestinationFolder
End If

Next


I am pretty sure this will work for you.

Thanks
Rahul

Rahul

unread,
Feb 11, 2009, 4:00:03 AM2/11/09
to
Hi Sarvesh,

Try this....

Dim sOriginFolder, sDestinationFolder, sFile, oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
sOriginFolder = "D:\Documents\P2P Dev\BoA_H2H\XML\"
sDestinationFolder = "D:\Documents\P2P Dev\BoA_H2H\XML\TrasnferXML\"
For Each sFile In oFSO.GetFolder(sOriginFolder).Files
If instr(1, sFile.Name, ".xml", 1) > 0 then
oFSO.MoveFile sFile, sDestinationFolder
End If

Next


I am pretty sure it will work for you.

Thanks
Rahul

sweta Rai

unread,
Sep 28, 2010, 6:33:40 AM9/28/10
to
I have a code which would copy a file from a location to another, make 2 copies of it and rename both.But when i try to rename, it is renaming the file at source folder. Pls suggest

Sub mycode()
Dim filesys, oFile, sName, oCount, dFile
'Set oCount = 0
Const sSourceFdr = "E:\VBS\"
Const sDestFdr = "E:\VBS\temp\"
Set filesys = CreateObject("Scripting.FileSystemObject")

For Each oFile In filesys.GetFolder(sSourceFdr).Files
On Error Resume Next
If InStr(1, oFile.Name, "Actuals") <> 0 Then

filesys.CopyFile oFile.Path, sDestFdr, OverWriteExisting


sName = Replace(oFile.Name, "Inter", "InterCA")
oFile.Name = sName
End If
Next
On Error GoTo 0

End Sub

> On Sunday, January 25, 2009 1:04 AM Sarvesh wrote:

> Hi,
>
> I am having different kind of files need to move from one drive to
> another based on the file name contains specified string by using
> vbscript. For example, i need to move the file that the filename
> contains string "mylog". Please help me to write vbscript to do this
> job.
>
> Thanks,
> Sarvesh


>> On Sunday, January 25, 2009 5:07 PM noon wrote:

>> Il giorno Fri, 23 Jan 2009 06:29:18 -0800 (PST), Sarvesh <sarves...@gmail.com> ha
>> scritto:


>>
>>
>> This asks dos to write a file with the pathnames of all the files you are looking for
>> (maybe).
>>
>> drive="c:\"
>> cmd = "dir "& trim(drive) & "*mylog* /s/b "
>> tmp = "c:\data\pathnames.txt"
>> Set WshShell = CreateObject("WScript.Shell")
>> WSHShell.Run "%comspec% /c " & cmd & " >" & tmp, 0, True
>>
>>
>> --
>> Giovanni Cenati (Bergamo, Italy)
>> Write to "Reventlov" at katamail com

>> http://digilander.libero.it/Cenati (Esempi e programmi in VbScript)
>> --


>>> On Thursday, January 29, 2009 10:53 AM Pegasus \(MVP\) wrote:

>>> "Sarvesh" <sarves...@gmail.com> wrote in message

>>> news:b6d16742-0962-4466...@41g2000yqf.googlegroups.com...


>>>
>>> You need to think about your requirements in more detail and post the
>>> following information:
>>> - Where are your files kept? In a single folder? In a directory tree?
>>> - Where do you want to move them to? To the root of another partition? To a
>>> folder on that partition? If so, what name? Do you wish to rebuild the
>>> source directory tree on the target partition?
>>> - What should happen if a file of the same name already exists on the target
>>> partition?
>>> - Can you show us the (partial) script solution you have developed so far?


>>>> On Saturday, January 31, 2009 11:38 PM Sarvesh wrote:

>>>> On Jan 26, 3:07=A0am, no...@no.void (Reventlov) wrote:
>>>> ail.com> ha
>>>> looking for
>>>> empi e programmi in VbScript)


>>>>
>>>> Hi,
>>>>
>>>> The above mentioned code is not moving any files. It is just creating
>>>> pathnames.txt file. I need to move the files that those filenames

>>>> contains string "mylog".
>>>>

>>>> Please help me to get the appropriate code.
>>>>
>>>> Thanks in Advance.
>>>>
>>>> Regards,
>>>> Sarvesh


>>>>> On Tuesday, February 03, 2009 8:41 AM Pegasus \(MVP\) wrote:

>>>>> "Sarvesh" <sarves...@gmail.com> wrote in message
>>>>> news:f11127d0-3ab3-431a...@s20g2000yqh.googlegroups.com...

>>>>> On Jan 29, 8:53 pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
>>>>>
>>>>> Hi,
>>>>>


>>>>>> On Wednesday, February 04, 2009 5:17 AM Sarvesh wrote:

>>>>>> On Jan 29, 8:53=A0pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
>>>>>> a
>>>>>> get


>>>>>> ?
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I am having the below code to move the files from one drive(c:) to
>>>>>> another(d:).
>>>>>>
>>>>>> Option Explicit
>>>>>>
>>>>>> Dim oFS, oFile, sFile
>>>>>>

>>>>>> Set oFS =3D WScript.CreateObject("Scripting.FileSystemObject")
>>>>>>
>>>>>> Const sSourceFdr =3D "C:\test1\"
>>>>>> Const sDestFdr =3D "D:\test2\"
>>>>>> Const nDays =3D 10


>>>>>>
>>>>>> For Each oFile In oFS.GetFolder(sSourceFdr).Files
>>>>>> On Error Resume Next
>>>>>> If DateDiff("d", oFile.DateLastModified, Now) > nDays Then
>>>>>> oFS.MoveFile oFile.Path, sDestFdr
>>>>>> End If
>>>>>> On Error Goto 0
>>>>>> Next

>>>>>> Set oFS =3D Nothing


>>>>>> WScript.Quit
>>>>>>
>>>>>> I need cut and paste the files those filename's contains "mylog" .
>>>>>>
>>>>>> Thanks,
>>>>>> Sarvesh


>>>>>>> On Wednesday, February 11, 2009 3:59 AM Rahu wrote:

>>>>>>> Hi Sarvesh,
>>>>>>>
>>>>>>> Try the below script...
>>>>>>>

>>>>>>> Dim sOriginFolder, sDestinationFolder, sFile, oFSO
>>>>>>> Set oFSO = CreateObject("Scripting.FileSystemObject")
>>>>>>> sOriginFolder = "D:\Documents\P2P Dev\BoA_H2H\XML\"
>>>>>>> sDestinationFolder = "D:\Documents\P2P Dev\BoA_H2H\XML\TrasnferXML\"
>>>>>>> For Each sFile In oFSO.GetFolder(sOriginFolder).Files
>>>>>>> If instr(1, sFile.Name, ".xml", 1) > 0 then
>>>>>>> oFSO.MoveFile sFile, sDestinationFolder
>>>>>>> End If
>>>>>>>
>>>>>>> Next
>>>>>>>
>>>>>>>

>>>>>>> I am pretty sure this will work for you.
>>>>>>>
>>>>>>> Thanks
>>>>>>> Rahul
>>>>>>>
>>>>>>> "Pegasus (MVP)" wrote:


>>>>>>>> On Wednesday, February 11, 2009 4:00 AM Rahul_Bangi wrote:

>>>>>>>> Hi Sarvesh,
>>>>>>>>
>>>>>>>> Try this....
>>>>>>>>
>>>>>>>> Dim sOriginFolder, sDestinationFolder, sFile, oFSO
>>>>>>>> Set oFSO = CreateObject("Scripting.FileSystemObject")
>>>>>>>> sOriginFolder = "D:\Documents\P2P Dev\BoA_H2H\XML\"
>>>>>>>> sDestinationFolder = "D:\Documents\P2P Dev\BoA_H2H\XML\TrasnferXML\"
>>>>>>>> For Each sFile In oFSO.GetFolder(sOriginFolder).Files
>>>>>>>> If instr(1, sFile.Name, ".xml", 1) > 0 then
>>>>>>>> oFSO.MoveFile sFile, sDestinationFolder
>>>>>>>> End If
>>>>>>>>
>>>>>>>> Next
>>>>>>>>
>>>>>>>>
>>>>>>>> I am pretty sure it will work for you.
>>>>>>>>
>>>>>>>> Thanks
>>>>>>>> Rahul
>>>>>>>>
>>>>>>>> "Sarvesh" wrote:


>>>>>>>> Submitted via EggHeadCafe - Software Developer Portal of Choice
>>>>>>>> ASP.NET HttpPostedFile Image Resizer
>>>>>>>> http://www.eggheadcafe.com/tutorials/aspnet/ba8d2418-6d67-40f7-989c-e90688058778/aspnet-httppostedfile-image-resizer.aspx

Dave "Crash" Dummy

unread,
Sep 28, 2010, 9:15:05 AM9/28/10
to
sweta Rai wrote:
> I have a code which would copy a file from a location to another, make 2 copies of it and rename both.But when i try to rename, it is renaming the file at source folder. Pls suggest
>
> Sub mycode()
> Dim filesys, oFile, sName, oCount, dFile
> 'Set oCount = 0
> Const sSourceFdr = "E:\VBS\"
> Const sDestFdr = "E:\VBS\temp\"
> Set filesys = CreateObject("Scripting.FileSystemObject")
>
> For Each oFile In filesys.GetFolder(sSourceFdr).Files
> On Error Resume Next
> If InStr(1, oFile.Name, "Actuals") <> 0 Then
>
> filesys.CopyFile oFile.Path, sDestFdr, OverWriteExisting
>
>
> sName = Replace(oFile.Name, "Inter", "InterCA")
> oFile.Name = sName
> End If
> Next
> On Error GoTo 0
>
> End Sub

Replace your IF...END IF code segment with this:

If InStr(1, oFile.Name, "Actuals") <> 0 Then

sName = Replace(oFile.Name, "Inter", "InterCA")

oFile.copy sDestFdr & sName
End If

--
Crash

"Facts are stubborn things, but statistics are more pliable."
~ Laurence J. Peter ~

Todd Vargo

unread,
Sep 28, 2010, 8:12:56 PM9/28/10
to

Cool, oFile.copy overwrites without a blink.

--
Todd Vargo

(Post questions to group only. Remove "z" to email personal messages)

Todd Vargo

unread,
Sep 28, 2010, 7:57:27 PM9/28/10
to
sweta Rai wrote:
> I have a code which would copy a file from a location to another, make
> 2 copies of it and rename both.But when i try to rename, it is renaming
> the file at source folder. Pls suggest
>
> Sub mycode()
> Dim filesys, oFile, sName, oCount, dFile
> 'Set oCount = 0
> Const sSourceFdr = "E:\VBS\"
> Const sDestFdr = "E:\VBS\temp\"
> Set filesys = CreateObject("Scripting.FileSystemObject")
>
> For Each oFile In filesys.GetFolder(sSourceFdr).Files
> On Error Resume Next
> If InStr(1, oFile.Name, "Actuals") <> 0 Then
>
> filesys.CopyFile oFile.Path, sDestFdr, OverWriteExisting

Your code does not set OverWriteExisting as a constant or variable.

>
>
> sName = Replace(oFile.Name, "Inter", "InterCA")
> oFile.Name = sName

^^^^^^^^^^
You have the code set to rename the source file above.


> End If
> Next
> On Error GoTo 0
>
> End Sub

The code does not make 2 copies as you mentioned and you are not clear on
what you want. I can not tell if you really wanted to create two copies with
different names but ISTM, best to just copy directly to the new name and
omit the rename process.

Sub mycode()
Dim filesys, oFile, sName

Const sSourceFdr = "E:\VBS\"
Const sDestFdr = "E:\VBS\temp\"

Const OverWriteExisting = True


Set filesys = CreateObject("Scripting.FileSystemObject")

'On Error Resume Next


For Each oFile In filesys.GetFolder(sSourceFdr).Files

If InStr(1, oFile.Name, "Actuals") <> 0 Then

sName = Replace(oFile.Name, "Inter", "InterCA")

filesys.CopyFile oFile.Path, sDestFdr & sName, OverWriteExisting

Eric Ahlman

unread,
Jul 13, 2011, 6:07:46 PM7/13/11
to
thanks that worked mostly for what I am trying to do. Is there a way to add options to NOT overwrite if it already exists in the destination folder a file by the same name? Also what about getting only the most recent version. In this scenario i have database backups. My software keeps like 8 full backups in one dir, and daily incrementals.

I only want to copy the latest version of the full backup (contains ~FULL in the file name) based on the date modified in the file structure.

Any help is greatly appreciated!

> On Sunday, January 25, 2009 1:04 AM Sarvesh wrote:

> Hi,
>
> I am having different kind of files need to move from one drive to
> another based on the file name contains specified string by using
> vbscript. For example, i need to move the file that the filename
> contains string "mylog". Please help me to write vbscript to do this
> job.
>
> Thanks,
> Sarvesh

>> On Sunday, January 25, 2009 5:07 PM noon wrote:

>> Il giorno Fri, 23 Jan 2009 06:29:18 -0800 (PST), Sarvesh <sarves...@gmail.com> ha
>> scritto:
>>
>>
>> This asks dos to write a file with the pathnames of all the files you are looking for
>> (maybe).
>>
>> drive="c:\"
>> cmd = "dir "& trim(drive) & "*mylog* /s/b "
>> tmp = "c:\data\pathnames.txt"
>> Set WshShell = CreateObject("WScript.Shell")
>> WSHShell.Run "%comspec% /c " & cmd & " >" & tmp, 0, True
>>
>>
>> --
>> Giovanni Cenati (Bergamo, Italy)
>> Write to "Reventlov" at katamail com
>> http://digilander.libero.it/Cenati (Esempi e programmi in VbScript)
>> --


>>> On Thursday, January 29, 2009 10:53 AM Pegasus \(MVP\) wrote:

>>> "Sarvesh" <sarves...@gmail.com> wrote in message

>>> news:b6d16742-0962-4466...@41g2000yqf.googlegroups.com...


>>>
>>> You need to think about your requirements in more detail and post the
>>> following information:
>>> - Where are your files kept? In a single folder? In a directory tree?
>>> - Where do you want to move them to? To the root of another partition? To a
>>> folder on that partition? If so, what name? Do you wish to rebuild the
>>> source directory tree on the target partition?
>>> - What should happen if a file of the same name already exists on the target
>>> partition?
>>> - Can you show us the (partial) script solution you have developed so far?

>>>> On Saturday, January 31, 2009 11:38 PM Sarvesh wrote:

>>>> On Jan 26, 3:07=A0am, no...@no.void (Reventlov) wrote:
>>>> ail.com> ha
>>>> looking for
>>>> empi e programmi in VbScript)
>>>>
>>>> Hi,
>>>>
>>>> The above mentioned code is not moving any files. It is just creating
>>>> pathnames.txt file. I need to move the files that those filenames

>>>> contains string "mylog".
>>>>

>>>> Please help me to get the appropriate code.
>>>>
>>>> Thanks in Advance.
>>>>
>>>> Regards,
>>>> Sarvesh

>>>>>> On Wednesday, February 04, 2009 5:17 AM Sarvesh wrote:

>>>>>> On Jan 29, 8:53=A0pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
>>>>>> a
>>>>>> get


>>>>>> ?
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I am having the below code to move the files from one drive(c:) to
>>>>>> another(d:).
>>>>>>
>>>>>> Option Explicit
>>>>>>
>>>>>> Dim oFS, oFile, sFile
>>>>>>

>>>>>> Set oFS =3D WScript.CreateObject("Scripting.FileSystemObject")
>>>>>>
>>>>>> Const sSourceFdr =3D "C:\test1\"
>>>>>> Const sDestFdr =3D "D:\test2\"

>>>>>> Const nDays =3D 10


>>>>>>
>>>>>> For Each oFile In oFS.GetFolder(sSourceFdr).Files
>>>>>> On Error Resume Next
>>>>>> If DateDiff("d", oFile.DateLastModified, Now) > nDays Then
>>>>>> oFS.MoveFile oFile.Path, sDestFdr
>>>>>> End If
>>>>>> On Error Goto 0
>>>>>> Next

>>>>>> Set oFS =3D Nothing


>>>>>> WScript.Quit
>>>>>>
>>>>>> I need cut and paste the files those filename's contains "mylog" .
>>>>>>
>>>>>> Thanks,
>>>>>> Sarvesh

>>>>>>> On Wednesday, February 11, 2009 3:59 AM Rahu wrote:

>>>>>>> Hi Sarvesh,
>>>>>>>
>>>>>>> Try the below script...
>>>>>>>
>>>>>>> Dim sOriginFolder, sDestinationFolder, sFile, oFSO
>>>>>>> Set oFSO = CreateObject("Scripting.FileSystemObject")
>>>>>>> sOriginFolder = "D:\Documents\P2P Dev\BoA_H2H\XML\"
>>>>>>> sDestinationFolder = "D:\Documents\P2P Dev\BoA_H2H\XML\TrasnferXML\"
>>>>>>> For Each sFile In oFSO.GetFolder(sOriginFolder).Files
>>>>>>> If instr(1, sFile.Name, ".xml", 1) > 0 then
>>>>>>> oFSO.MoveFile sFile, sDestinationFolder
>>>>>>> End If
>>>>>>>
>>>>>>> Next
>>>>>>>
>>>>>>>
>>>>>>> I am pretty sure this will work for you.
>>>>>>>
>>>>>>> Thanks
>>>>>>> Rahul
>>>>>>>
>>>>>>> "Pegasus (MVP)" wrote:


>>>>>>>> On Wednesday, February 11, 2009 4:00 AM Rahul_Bangi wrote:

>>>>>>>> Hi Sarvesh,
>>>>>>>>
>>>>>>>> Try this....
>>>>>>>>

>>>>>>>> Dim sOriginFolder, sDestinationFolder, sFile, oFSO
>>>>>>>> Set oFSO = CreateObject("Scripting.FileSystemObject")
>>>>>>>> sOriginFolder = "D:\Documents\P2P Dev\BoA_H2H\XML\"
>>>>>>>> sDestinationFolder = "D:\Documents\P2P Dev\BoA_H2H\XML\TrasnferXML\"
>>>>>>>> For Each sFile In oFSO.GetFolder(sOriginFolder).Files
>>>>>>>> If instr(1, sFile.Name, ".xml", 1) > 0 then
>>>>>>>> oFSO.MoveFile sFile, sDestinationFolder
>>>>>>>> End If
>>>>>>>>
>>>>>>>> Next
>>>>>>>>
>>>>>>>>

>>>>>>>> I am pretty sure it will work for you.
>>>>>>>>
>>>>>>>> Thanks
>>>>>>>> Rahul
>>>>>>>>
>>>>>>>> "Sarvesh" wrote:


>>>>>>>>> On Tuesday, September 28, 2010 6:33 AM sweta Rai wrote:

>>>>>>>>> I have a code which would copy a file from a location to another, make 2 copies of it and rename both.But when i try to rename, it is renaming the file at source folder. Pls suggest
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Sub mycode()
>>>>>>>>>
>>>>>>>>> Dim filesys, oFile, sName, oCount, dFile
>>>>>>>>>
>>>>>>>>> 'Set oCount = 0
>>>>>>>>>
>>>>>>>>> Const sSourceFdr = "E:\VBS\"
>>>>>>>>>
>>>>>>>>> Const sDestFdr = "E:\VBS\temp\"
>>>>>>>>>
>>>>>>>>> Set filesys = CreateObject("Scripting.FileSystemObject")
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> For Each oFile In filesys.GetFolder(sSourceFdr).Files
>>>>>>>>>

>>>>>>>>> On Error Resume Next
>>>>>>>>>

>>>>>>>>> If InStr(1, oFile.Name, "Actuals") <> 0 Then
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> filesys.CopyFile oFile.Path, sDestFdr, OverWriteExisting
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>

>>>>>>>>> sName = Replace(oFile.Name, "Inter", "InterCA")
>>>>>>>>>
>>>>>>>>> oFile.Name = sName
>>>>>>>>>

0 new messages