Moving local folder system to remote ftp folder 
Author Message
 Moving local folder system to remote ftp folder

Dear

I want to move my local folder to remote ftp folder. Within the folder, a
lot of files and sub and sub-sub,... folders exist. I need to port them as
is with the same file-folder system. I worry this can be a bomb question(I
don't know exact English :).

I've seen one example in Tobias Weltner's book(Windows Script Secrets). It
looks non-sensical using component.

Has anyone seen good example? After I port them, to delete all of them,
there should be cooked list remained. Tough is that FTP command doesn't
allow deleting a folder having files within it.

Does anyone have an idea or example?



Thu, 15 Dec 2005 15:07:34 GMT  
 Moving local folder system to remote ftp folder
This works.

set fso=createobject("scripting.filesystemobject")
set ws=createobject("wscript.shell")
set xmldoc1=createobject("msxml2.domdocument.4.0")

const root1="c:\layx"

op=inputbox("put=1, del=2")
if op="" then wscript.quit

set file1=fso.createTextfile("c:\sync.txt")
file1.writeLine "open ftp.megapass.co.kr"
file1.writeLine "hp4444"
file1.writeLine "pwd"

execute "sync" & op

file1.writeLine "bye"

ws.run "ftp -s:c:\sync.txt"
xmldoc1.save "layx.xml"

sub sync1
 xmldoc1.loadxml "<x/>"
 xmldoc1.save root1 & "\sync.xml"

 set fd=fso.getfolder(root1)

 recur fd, xmldoc1.documentelement
 xmldoc1.save root1 & "\sync.xml"

end sub

sub sync2
 xmldoc1.async=false
 if not xmldoc1.load( _
  "http://www.megapass.co.kr/~hp4444/layx/sync.xml") then

  msgbox 0
  wscript.quit
 end if

 for each fle in xmldoc1.selectnodes("//fle")
  a=fle.attributes(0).text
  a=mid(a, 4)
  file1.writeLine "del " & a
 next

 p="*/fdr"

 do until xmldoc1.selectnodes(p).length=0
  p="*/" & p
 loop

 p=mid(p, 3)

 do until p="fdr"
  for each nd in xmldoc1.selectNodes(p)
   t=nd.attributes(0).text
   file1.writeLine "rmdir " & mid(t, 4)
  next

  p=mid(p, 3)

 loop

end sub

sub recur(byval fd1, byval node)
 pth=lcase(fd1.path)
 pth=replace(pth, "\", "/")
 file1.writeLine "mkdir " & mid(pth, 4)

 set n1=xmldoc1.createelement("fdr")
 n1.setattribute "pth", pth

 node.appendchild n1

 for each f in fd1.files
  fname1=pth & "/" & f.name
  fname2=mid(pth,4) & "/" & f.name

  file1.writeLine "put " & fname1 & " " & fname2

  set n2=xmldoc1.createelement("fle")
  n2.setAttribute "pth", fname1
  n1.appendchild n2
 next

 for each fd2 in fd1.subfolders
  recur fd2, n1
 next

end sub


Quote:
> Dear

> I want to move my local folder to remote ftp folder. Within the folder, a
> lot of files and sub and sub-sub,... folders exist. I need to port them as
> is with the same file-folder system. I worry this can be a bomb question(I
> don't know exact English :).

> I've seen one example in Tobias Weltner's book(Windows Script Secrets). It
> looks non-sensical using component.

> Has anyone seen good example? After I port them, to delete all of them,
> there should be cooked list remained. Tough is that FTP command doesn't
> allow deleting a folder having files within it.

> Does anyone have an idea or example?



Sat, 17 Dec 2005 01:25:30 GMT  
 Moving local folder system to remote ftp folder
Here is a cooked version. You may want to edit only the first five lines.

const root1="c:\layx"
const cmdOpen="open ftp.megapass.co.kr"
const uid1="hp4444"
const pwd1="my-pwd"
const remoteXml="http://www.megapass.co.kr/~hp4444/layx/sync.xml"

set fso=createobject("scripting.filesystemobject")
set ws=createobject("wscript.shell")
set xmldoc1=createobject("msxml2.domdocument.4.0")

op=inputbox("put=1, del=2")
if op="" then wscript.quit

set file1=fso.createTextfile("c:\sync.txt")
file1.writeLine cmdOpen
file1.writeLine uid1
file1.writeLine pwd1

execute "sync" & op

file1.writeLine "bye"

ws.run "ftp -s:c:\sync.txt"

sub sync1
 xmldoc1.loadxml "<x/>"
 xmldoc1.save root1 & "\sync.xml"

 set fd=fso.getfolder(root1)

 recur fd, xmldoc1.documentelement
 xmldoc1.save root1 & "\sync.xml"

end sub

sub sync2
 xmldoc1.async=false
 if not xmldoc1.load(remoteXml) then

  msgbox 0
  wscript.quit
 end if

 for each fle in xmldoc1.selectnodes("//fle")
  a=fle.attributes(0).text
  a=mid(a, 4)
  file1.writeLine "del " & a
 next

 p="*/fdr"

 do until xmldoc1.selectnodes(p).length=0
  p="*/" & p
 loop

 p=mid(p, 3)

 do until p="fdr"
  for each nd in xmldoc1.selectNodes(p)
   t=nd.attributes(0).text
   file1.writeLine "rmdir " & mid(t, 4)
  next

  p=mid(p, 3)

 loop

end sub

sub recur(byval fd1, byval node)
 pth=lcase(fd1.path)
 pth=replace(pth, "\", "/")
 file1.writeLine "mkdir " & mid(pth, 4)

 set n1=xmldoc1.createelement("fdr")
 n1.setattribute "pth", pth

 node.appendchild n1

 for each f in fd1.files
  fname1=pth & "/" & f.name
  fname2=mid(pth,4) & "/" & f.name

  file1.writeLine "put " & fname1 & " " & fname2

  set n2=xmldoc1.createelement("fle")
  n2.setAttribute "pth", fname1
  n1.appendchild n2
 next

 for each fd2 in fd1.subfolders
  recur fd2, n1
 next

end sub


Quote:
> This works.

> set fso=createobject("scripting.filesystemobject")
> set ws=createobject("wscript.shell")
> set xmldoc1=createobject("msxml2.domdocument.4.0")

> const root1="c:\layx"

> op=inputbox("put=1, del=2")
> if op="" then wscript.quit

> set file1=fso.createTextfile("c:\sync.txt")
> file1.writeLine "open ftp.megapass.co.kr"
> file1.writeLine "hp4444"
> file1.writeLine "pwd"

> execute "sync" & op

> file1.writeLine "bye"

> ws.run "ftp -s:c:\sync.txt"
> xmldoc1.save "layx.xml"

> sub sync1
>  xmldoc1.loadxml "<x/>"
>  xmldoc1.save root1 & "\sync.xml"

>  set fd=fso.getfolder(root1)

>  recur fd, xmldoc1.documentelement
>  xmldoc1.save root1 & "\sync.xml"

> end sub

> sub sync2
>  xmldoc1.async=false
>  if not xmldoc1.load( _
>   "http://www.megapass.co.kr/~hp4444/layx/sync.xml") then

>   msgbox 0
>   wscript.quit
>  end if

>  for each fle in xmldoc1.selectnodes("//fle")
>   a=fle.attributes(0).text
>   a=mid(a, 4)
>   file1.writeLine "del " & a
>  next

>  p="*/fdr"

>  do until xmldoc1.selectnodes(p).length=0
>   p="*/" & p
>  loop

>  p=mid(p, 3)

>  do until p="fdr"
>   for each nd in xmldoc1.selectNodes(p)
>    t=nd.attributes(0).text
>    file1.writeLine "rmdir " & mid(t, 4)
>   next

>   p=mid(p, 3)

>  loop

> end sub

> sub recur(byval fd1, byval node)
>  pth=lcase(fd1.path)
>  pth=replace(pth, "\", "/")
>  file1.writeLine "mkdir " & mid(pth, 4)

>  set n1=xmldoc1.createelement("fdr")
>  n1.setattribute "pth", pth

>  node.appendchild n1

>  for each f in fd1.files
>   fname1=pth & "/" & f.name
>   fname2=mid(pth,4) & "/" & f.name

>   file1.writeLine "put " & fname1 & " " & fname2

>   set n2=xmldoc1.createelement("fle")
>   n2.setAttribute "pth", fname1
>   n1.appendchild n2
>  next

>  for each fd2 in fd1.subfolders
>   recur fd2, n1
>  next

> end sub



> > Dear

> > I want to move my local folder to remote ftp folder. Within the folder,
a
> > lot of files and sub and sub-sub,... folders exist. I need to port them
as
> > is with the same file-folder system. I worry this can be a bomb
question(I
> > don't know exact English :).

> > I've seen one example in Tobias Weltner's book(Windows Script Secrets).
It
> > looks non-sensical using component.

> > Has anyone seen good example? After I port them, to delete all of them,
> > there should be cooked list remained. Tough is that FTP command doesn't
> > allow deleting a folder having files within it.

> > Does anyone have an idea or example?



Sat, 17 Dec 2005 23:34:14 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Determining if a folder is a local pst folder or a imap (server folder)

2. Moving file to ftp folder

3. Syncing public folders with local folders automatically

4. Syncing public folders with local folders automatically

5. Move local folders

6. Click button to move folders contents to another folder

7. How to access million files from a folder and move them to separate folders

8. MAPI folder and System Folders

9. folder in a folder in a folder...

10. Build XML of folders, sub folders and files from specified folder

11. How to delete folders/files within a folder but not the folder itself

12. Access to file system on remote FTP-server

 

 
Powered by phpBB® Forum Software