I need Script that to move files to different Folders.... It could be batch or vbs, all I need is somethings that works well. I would prefer something that would read the first three files and move files to the locations individual server.
I have the following files as example....
MHG ICU BKUP SCHED.DOC
MHG CCU BKUP SCHED.PDF
ELA ER BKUP SCHED.DOC
ELA ICU BKUP SCHED.DOC
CHHP ICU BKUP SCHED.DOC
CHHP CCU BKUP SCHED.DOC
CPH ER BKUP SCHED.DOC
CPH PHI BKUP SCHED.DOC
The script should get the first three letter of the files and copy them to the following
MHG*.* TO \\10.X.X.20\emarbackup$
ELA*.* to \\10.X.X.15\emarbackup$
CHH*.* to \\10.X.X.30\emarbackup$
CPH*.* to \\10.X.X.35\emarbackup$
I've used the following VBS to move the files, but doesn't copy to different servers and when there is an file with the 2 leading characters like "PP EMAR BACKUP.DOC" I get an error message and it stops working.
strSourceFolder = "C:\Temp\EMARTEST"
If Right(strSourceFolder, 1) <> "\" Then strSourceFolder = strSourceFolder & "\"
Set fso = CreateObject("Scripting.FileSystemObject")
Set objSource = fso.GetFolder(strSourceFolder)
For Each oFile In objSource.Files
strFirst3 = Left(oFile.Name, 3)
If Not fso.FolderExists(strSourceFolder & strFirst3) Then
fso.CreateFolder strSourceFolder & strFirst3
fso.MoveFile strSourceFolder & oFile.Name, strSourceFolder & strFirst3 & "\"