I need this script to move folders from a list, text file. I am new to VBS
and can't get it to work. Any help would be greatly appreciated.

set fso = CreateObject("Scripting.FileSystemObject")
set oFile = fso.OpenTextFile("C:\listcommands.txt", 1, False)


Do while (oFile.AtEndOfStream <> True )
strFolder = oFile.ReadLine()

Set oFolder = fso.GetFolder(strFolder)

oFolder.Copy("C:\TrashBin\" & http://oFolder.Name/)
oFolder.Delete

Loop

oFile.Close

Re: Script to move folders from a list text file by McKirahan

McKirahan
Fri Nov 30 10:52:05 PST 2007

"WTB" <WTB@discussions.microsoft.com> wrote in message
news:0AF1D07B-7FF5-469B-A3B1-006068F20F7C@microsoft.com...
> I need this script to move folders from a list, text file. I am new to VBS
> and can't get it to work. Any help would be greatly appreciated.
>
> set fso = CreateObject("Scripting.FileSystemObject")
> set oFile = fso.OpenTextFile("C:\listcommands.txt", 1, False)
>
>
> Do while (oFile.AtEndOfStream <> True )
> strFolder = oFile.ReadLine()
>
> Set oFolder = fso.GetFolder(strFolder)
>
> oFolder.Copy("C:\TrashBin\" & http://oFolder.Name/)
> oFolder.Delete
>
> Loop
>
> oFile.Close

Perhaps you should remove this line
Set oFolder = fso.GetFolder(strFolder)
and change thesel lines
oFolder.Copy("C:\TrashBin\" & http://oFolder.Name/)
oFolder.Delete
to
If fso.FolderExists(strFolder) Then
fso.MoveFolder(strFolder, "C:\TrashBin\")
End If

What does an entry in your text file look like?
Does it include a drive letter?
That would affect the MoveFolder()...



Re: Script to move folders from a list text file by WTB

WTB
Fri Nov 30 11:16:01 PST 2007



"McKirahan" wrote:

> "WTB" <WTB@discussions.microsoft.com> wrote in message
> news:0AF1D07B-7FF5-469B-A3B1-006068F20F7C@microsoft.com...
> > I need this script to move folders from a list, text file. I am new to VBS
> > and can't get it to work. Any help would be greatly appreciated.
> >
> > set fso = CreateObject("Scripting.FileSystemObject")
> > set oFile = fso.OpenTextFile("C:\listcommands.txt", 1, False)
> >
> >
> > Do while (oFile.AtEndOfStream <> True )
> > strFolder = oFile.ReadLine()
> >
> > Set oFolder = fso.GetFolder(strFolder)
> >
> > oFolder.Copy("C:\TrashBin\" & http://oFolder.Name/)
> > oFolder.Delete
> >
> > Loop
> >
> > oFile.Close
>
> Perhaps you should remove this line
> Set oFolder = fso.GetFolder(strFolder)
> and change thesel lines
> oFolder.Copy("C:\TrashBin\" & http://oFolder.Name/)
> oFolder.Delete
> to
> If fso.FolderExists(strFolder) Then
> fso.MoveFolder(strFolder, "C:\TrashBin\")
> End If
>
> What does an entry in your text file look like?
> Does it include a drive letter?
> That would affect the MoveFolder()...
>
>
> The text file is only a list of the folders in the directory I need to move. Thank you for the quick reply.

Re: Script to move folders from a list text file by WTB

WTB
Fri Nov 30 11:59:01 PST 2007



"WTB" wrote:

>
>
> "McKirahan" wrote:
>
> > "WTB" <WTB@discussions.microsoft.com> wrote in message
> > news:0AF1D07B-7FF5-469B-A3B1-006068F20F7C@microsoft.com...
> > > I need this script to move folders from a list, text file. I am new to VBS
> > > and can't get it to work. Any help would be greatly appreciated.
> > >
> > > set fso = CreateObject("Scripting.FileSystemObject")
> > > set oFile = fso.OpenTextFile("C:\listcommands.txt", 1, False)
> > >
> > >
> > > Do while (oFile.AtEndOfStream <> True )
> > > strFolder = oFile.ReadLine()
> > >
> > > Set oFolder = fso.GetFolder(strFolder)
> > >
> > > oFolder.Copy("C:\TrashBin\" & http://oFolder.Name/)
> > > oFolder.Delete
> > >
> > > Loop
> > >
> > > oFile.Close
> >
> > Perhaps you should remove this line
> > Set oFolder = fso.GetFolder(strFolder)
> > and change thesel lines
> > oFolder.Copy("C:\TrashBin\" & http://oFolder.Name/)
> > oFolder.Delete
> > to
> > If fso.FolderExists(strFolder) Then
> > fso.MoveFolder(strFolder, "C:\TrashBin\")
> > End If
> >
> > What does an entry in your text file look like?
> > Does it include a drive letter?
> > That would affect the MoveFolder()...
> >
> >
> > The text file is only a list of the folders in the directory I need to move. Thank you for the quick reply.

That did the trick after I removed the parentheses. Thank you for the help.