[AccessD] Move Folder

Stuart McLachlan stuart at lexacorp.com.pg
Mon Apr 26 19:40:00 CDT 2010


Function MoveDir(Source as String, Destination as String)
    Dim strShell as String
    strShell = "Robocopy """ & Source & """ """ & Destination & """   /E /COPYALL /MOVE "
    Shell strShell
End Function

Note the escaped quotes around Source and Destination to handle paths containing spaces.

If you want to wait for this to finish before doing anything else, refer to the list thread 
"Shelling to a batch file" on 6/7 March 2010 for a ShellWait() function.

-- 
Stuart

On 26 Apr 2010 at 17:04, Rocky Smolin wrote:

> Well, client wants me to send a module with a function that accepts two
> arguments - source folder, and target path.  
> 
> R
> 
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Stuart McLachlan
> Sent: Monday, April 26, 2010 4:52 PM
> To: Access Developers discussion and problem solving
> Subject: Re: [AccessD] Move Folder
> 
> I've never looked at Robocopy before.  I just found that it comes build in
> with Vista and later so typed "Robocopy /?"  at the commandline. 
> 
> I'd like to retract my previous response.  My new response is:
> 
> My preferred way to move a folder through code is by building a Robocopy
> command string 
> and passing it to a Shell()    :-)
> 
> 
> --
> Stuart
> 
> 
> 
> On 26 Apr 2010 at 16:17, Rocky Smolin wrote:
> 
> > Good idea.  I used FSO once before.  He's a bit more adept as a user than
> > most - knows how to set a reference if he has to.
> > 
> > But I'm forwarding Drew's suggestion of Robocopy to see if that will do
> the
> > job.  
> > 
> > R
> > 
> > 
> > -----Original Message-----
> > From: accessd-bounces at databaseadvisors.com
> > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Stuart
> McLachlan
> > Sent: Monday, April 26, 2010 3:48 PM
> > To: Access Developers discussion and problem solving
> > Subject: Re: [AccessD] Move Folder
> > 
> > If you use a File System Object, it's quite simple - I think I have some
> > code somewhere which I will try to dig out. 
> > 
> > But I don't like using FSO because it relies on Scripting being available.
> > 
> > Without it, you have to re-iterate through the subfolder, recreate them in
> a
> > new location and filecopy/kill everything in the first location.  I may
> have
> > some code somewhere for that to.
> > 
> > --
> > Stuart
> > 
> > 
> > 
> > On 26 Apr 2010 at 15:36, Rocky Smolin wrote:
> > 
> > > Dear List:
> > > 
> > > What is the best way (through code, of course) to move a folder and all
> of
> > > its subfolders and files to a new location?
> > > 
> > >  
> > > 
> > > MTIA
> > > 
> > >  
> > > 
> > > Rocky Smolin
> > > 
> > > Beach Access Software
> > > 
> > > 858-259-4334
> > > 
> > > www.e-z-mrp.com <http://www.e-z-mrp.com/> 
> > > 
> > > www.bchacc.com <http://www.bchacc.com/> 
> > > 
> > >  
> > > 
> > >  
> > > 
> > > 
> > 
> > 
> > -- 
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> > 
> > -- 
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> 
> 
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com





More information about the AccessD mailing list