Multi-folder update's

S

Steven Burn

Okay, here's what I'm trying to do;

I have 3 folders in the root of my site;

/upg - contains upgraded file's
/folder1 (contains 500+ sub-folders)
/folder 2 (contains 300+ sub-folders (increasing daily))

Now, what I'm wanting to do is copy the files from the "upg" folder, to
every sub-folder in "folder1" and "folder2". I wrote the code below to
acheive this, but for some reason, it's additionally copying all of the
folders from the first folder, to the second (i.e. the contents of folder1
to folder2..... which it is not supposed to be doing).

'// Begin
<%
'// How this works;
'//
'// 1. Run script once to copy file's to folder1's sub-folders
'// 2. Change: set flds = fso.getfolder(server.mappath("folder1"))
'// to: set flds = fso.getfolder(server.mappath("folder2"))
'// 3. Run again to copy file's to folder2's sub-folders

'// shouldn't really be necessary but it keeps erroring if there's no
timeout specified.
server.scripttimeout = "5000"

dim fso
set fso = createobject("scripting.filesystemobject")

'// Set to folder1, is changed to folder2 when folder1 is complete
set flds = fso.getfolder(server.mappath("folder1"))

for each fld in flds.subfolders
fso.Copyfolder Server.MapPath("upg\"), fld.path, true
next

set fso = nothing
set flds = nothing
set fld = nothing

response.write "Done"

%>
'// End


--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Personal favourites

Practically Nerded - http://mvps.org/PracticallyNerded/
Bugs, Glitches n stuff - http://mvps.org/inetexplorer/Darnit.htm
Calendar of Updates - http://www.dozleng.com/updates/index.php?&act=calendar
 
S

Steven Burn

Ray at said:

Ray, I know, and I must apologise (I've just got this PC back after it went
down, and had problems remembering which NG's I was sub-scribed to (couldn't
find this one until around 2 mins before I posted).

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Personal favourites

Practically Nerded - http://mvps.org/PracticallyNerded/
Bugs, Glitches n stuff - http://mvps.org/inetexplorer/Darnit.htm
Calendar of Updates - http://www.dozleng.com/updates/index.php?&act=calendar
 
S

Steven Burn

hehe, as if one of me isn't bad enough <g> (atleast, thats what they keep
telling me, hehe)

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Personal favourites

Practically Nerded - http://mvps.org/PracticallyNerded/
Bugs, Glitches n stuff - http://mvps.org/inetexplorer/Darnit.htm
Calendar of Updates - http://www.dozleng.com/updates/index.php?&act=calendar


Ray at said:
I thought maybe it was a different Steven Burn or something! :]

Ray at work

Steven Burn said:
Ray, I know, and I must apologise (I've just got this PC back after it went
down, and had problems remembering which NG's I was sub-scribed to (couldn't
find this one until around 2 mins before I posted).

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Personal favourites

Practically Nerded - http://mvps.org/PracticallyNerded/
Bugs, Glitches n stuff - http://mvps.org/inetexplorer/Darnit.htm
Calendar of Updates - http://www.dozleng.com/updates/index.php?&act=calendar
 
R

Ray at

Here is one way that may work:


dim fso
set fso = createobject("scripting.filesystemobject")



Set fso = CreateObject("scripting.filesystemobject")

Set SourceFolder = fso.GetFolder(Server.MapPath("upg"))
Set TargetFolder = fso.GetFolder(Server.MapPath("folder1"))
Call CopyThemAll(SourceFolder, TargetFolder)
Set TargetFolder = fso.GetFolder(Server.MapPath("folder1"))
Call CopyThemAll(SourceFolder, TargetFolder)


Sub CopyThemAll(SourceFolder, TargetFolder)
Set oFiles = SourceFolder.Files
Set oSubDirs = TargetFolder.SubFolders
For Each oSubDir In oSubDirs
For Each oFile In oFiles
oFile.Copy oSubDir.Path & "\"
Next
Next
End Sub



Ray at work
 
S

Steven Burn

hehe OI!..... tis sposed to me be thanking you.... <vbg>

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Personal favourites

Practically Nerded - http://mvps.org/PracticallyNerded/
Bugs, Glitches n stuff - http://mvps.org/inetexplorer/Darnit.htm
Calendar of Updates - http://www.dozleng.com/updates/index.php?&act=calendar


Ray at said:
Cool. :] Thanks.

Ray at work

Steven Burn said:
Ray, thought you'd like to know, it worked like a charm :eek:), thanks again.

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Personal favourites

Practically Nerded - http://mvps.org/PracticallyNerded/
Bugs, Glitches n stuff - http://mvps.org/inetexplorer/Darnit.htm
Calendar of Updates - http://www.dozleng.com/updates/index.php?&act=calendar
 

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

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top