Jump to content
Sign in to follow this  
bettereyes1

Moving or Copying Directories

Recommended Posts

bettereyes1

It would be really nice if there were a DirCopy or DirMove command, that would let you copy (or move) an entire directory, plus all of it's files and sub-folders in one easy step. The help file states that the FileMove function can move directories, but I have not been able to get that to work at all. I don't know if it's a bug, or if it's just to painfully obvious for me to see how to do it. Anyone have any ideas how I could do this? Thanks!

Share this post


Link to post
Share on other sites
sykes

Sounds like a good idea to me ... how about a DirRename as well? Could come in handy from time to time


We have enough youth. How about a fountain of SMART?

Share this post


Link to post
Share on other sites
CyberSlug

The windows dir command might help....

Displays a list of files and subdirectories in a directory.

DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N]
  [/O[[:]sortorder]] [/P] [/Q] [/S] [/T[[:]timefield]] [/W] [/X] [/4]

Also, see xcopy

Copies files and directory trees.

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
                           [/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
                           [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z]
                           [/EXCLUDE:file1[+file2][+file3]...]
Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites
bettereyes1

I was hoping to be able to do this without calling a DOS command, but you're right, the XCOPY command would work perfectly to copy those files. Possibly even the DOS MOVE command also. Thanks for your suggestion!

Share this post


Link to post
Share on other sites
niranjan8shh

....., the XCOPY command would work perfectly to copy those files.

Beware though that xcopy behaves differently in NT4 W2k and XP, in case your script has to work on multiple systems. Of particular significance is /Y which is not understood by NT4, as well as that xcopy on NT4 keeps asking if the file to be copied is a file or a directory if folders do not exist in advance.

I found it the hard way. :whistle:

regards

niranjan

Share this post


Link to post
Share on other sites
jpm

The dir*** is included in the dbg-bastard stuff under the filemove

Just ask Jon to have time to integrate it.

:whistle:

Share this post


Link to post
Share on other sites
Valik

I'm sure that when I tested the FileMove command it happily moved/renamed entire directories.  I'll have to recheck.

I just tested FileMove on Windows XP SP-1 and it worked fine for both moving and renaming directories.

Share this post


Link to post
Share on other sites
Valik

One thing I didn't see anybody mention is that all directories along the path you are moving to have to exist or FileMove won't do anything. For example, given this directory structure:

C:\Folder To Move

C:\Another Folder

FileMove("C:\Folder To Move", "C:\Another Folder\Moved Here")

The above works, "Folder To Move" will be moved and renamed.

FileMove("C:\Folder To Move", "C:\Another Folder\Sub\Not Moved")

This will not work since the directory "Sub" doesn't exist. FileMove returns 1 to indicate failure. Maybe you were trying to do something like the above and that's why FileMove wouldn't work?

Share this post


Link to post
Share on other sites
bettereyes1

Hey, thanks for all the help. Yes, I was trying to use the move command to move a specific folder (such as "C:\Program Files\My Program\*.*"), and all it's subdirectories, to a new folder such as "\\Server Name\Share Name\Backups".

I was hoping it would also move (or create) empty folders, and also move any files that had the Read-Only attribute set. I believe the problem was that any Read-Only files would not be copied/moved correctly.

I haven't tried this with the new beta 90 release yet however.

Thanks again!

Jeff

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.