Home All Groups Group Topic Archive Search About

copying files multiple folders to single folder



Author
13 Oct 2007 12:08 PM
Vemula
Hi can some one help me.
I am copying the files whouse location is given ina text file ie.
coomputerlist.txt to a folder d:\archive.I am reading the contents of the
file from where i will pick the source location of the file.all the files
here are located at different folders.
when iam running the script iam getting an error: filenot found.I think it
is unable to read the source file in the methord objFSO.CopyFile filename
"D:\Archive\"
which in a variable filename.
can some help me its very urgent.

Dim filename
Const OverwriteExisting = True
Const inputfile = "c:\computerlist.txt"
Set ifso = CreateObject("Scripting.Filesystemobject")
Set ifile = iFSO.OpenTextFile(inputfile)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Do until ifile.AtEndOfLine
Filename = ifile.ReadLine
objFSO.CopyFile filename "D:\Archive\"
Loop

Author
13 Oct 2007 5:37 PM
Al Dunbar
Show quote
"Vemula" <Vem***@discussions.microsoft.com> wrote in message
news:8F570640-B8C8-4D4D-A2DD-86F984A49CDC@microsoft.com...
> Hi can some one help me.
> I am copying the files whouse location is given ina text file ie.
> coomputerlist.txt to a folder d:\archive.I am reading the contents of the
> file from where i will pick the source location of the file.all the files
> here are located at different folders.
> when iam running the script iam getting an error: filenot found.I think it
> is unable to read the source file in the methord objFSO.CopyFile filename
> "D:\Archive\"
> which in a variable filename.
> can some help me its very urgent.
>
> Dim filename
> Const OverwriteExisting = True
> Const inputfile = "c:\computerlist.txt"
> Set ifso = CreateObject("Scripting.Filesystemobject")
> Set ifile = iFSO.OpenTextFile(inputfile)
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Do until ifile.AtEndOfLine
> Filename = ifile.ReadLine

I'd suggest that you add code to determine exactly what has been read into
the variable, perhaps something like:

    wscript.echo "[" & filename & "]"

It could be, for example, that the filenames listed in the text file have a
stray blank character on the end, or that the path is not fully qualified.

/Al

Show quote
> objFSO.CopyFile filename "D:\Archive\"
> Loop

AddThis Social Bookmark Button