MoveFile problem

P

Patrice

Hi,
I want to move images from a folder to specific subfolders.
The script below generates the following error:
a.. Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required:'[undefined]'

<%
sub moveImagesToFolder(Folder)
dim fs,fo,x,text,Foldername,fm,f1
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fo=fs.GetFolder(Server.MapPath(Folder))
for each x in fo.files
text=Len(x.Name)-4
Foldername=Left(x.Name,text)
set f1 = fs.GetFile(x)

'/////here is where the error is targeted: don't know why!////
set fm=fs.MoveFile(f1,"C:\Inetpub\wwwroot\"&Folder&"\"&Foldername&"\")

set fm=nothing
set f1=nothing
next
set fs=nothing
set fo=nothing
end sub

%>

Can someone help?
Thx
 
R

Ray Costanzo [MVP]

The .MoveFile method doesn't return an object. Also, the first argument is
to be a file path, not a file object.


fs.MoveFile path1, path2

Ray at work
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top