Sign in to follow this  
Followers 0
hebi

copy all the files inside of a directory with subd

23 posts in this topic

Sorry, maybe I'm too stupid but i cant find a command that copies all the content of a directory to another directory including subdirs

can anyone help me out?

Share this post


Link to post
Share on other sites



I guess FileCopy would be too obvious?

*** Matt @ MPCS

Share this post


Link to post
Share on other sites

I guess FileCopy would be too obvious?

*** Matt @ MPCS

<{POST_SNAPBACK}>

including subdirs? :)

Share this post


Link to post
Share on other sites

including subdirs? :)

<{POST_SNAPBACK}>

I didnt think I should have to point it out but how about DirCopy???

*** Matt @ MPCS

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I didnt think I should have to point it out but how about DirCopy???

*** Matt @ MPCS

<{POST_SNAPBACK}>

not the dir itself only the content of a directory

like this:

cp -R C:/dummy/* C:/dummy/

Edited by hebi

Share this post


Link to post
Share on other sites

So you want to copy the files of a tree but not the tree structure itself?

*** Matt @ MPCS

Share this post


Link to post
Share on other sites

ok: i want to copy the content (with all subdirs and trees and blah) of direcotry A to direcotry B

in unix:

cp -R /dummy/* /dummy2/

Share this post


Link to post
Share on other sites

If you have a tree that looks like this:

/

-etc

--subfolder

---subfile1

--file1

-etc2

and you execute the command cp -R /etc /etc2 do you expect the new tree to look like:

/

-etc

--subfolder

---subfile1

--file1

-etc2

--subfolder

---subfile1

--file1

or:

/

-etc

--subfolder

---subfile1

--file1

-/etc2

--file1

--subfile1

?

*** Matt @ MPCS

Share this post


Link to post
Share on other sites

/

-etc

--subfolder

---subfile1

--file1

-etc2

--subfolder

---subfile1

--file1

like that ^^^:)

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Ok there is not a command... you can use windows copy using the runwait function... or manipulate the script on this thread to get what you are looking for.

*** Matt @ MPCS

EDIT: fixed link

Edited by Matt @ MPCS

Share this post


Link to post
Share on other sites

Ok there is not a command... you can use windows copy using the runwait function... or manipulate the script on this thread to get what you are looking for.

*** Matt @ MPCS

EDIT: fixed link

<{POST_SNAPBACK}>

um, why not FileCopy("C:\dir1\*.*", "C:\dir2\*.*") ? FileCopy will copy directories.

"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

i did something like the runwait command too

$destination = StringFormat("%s",$instpath)
$source = StringFormat("%s\Server",$source)
$command = StringFormat("xcopy %s %s /E /M",$source,$destination)
RunWait($command)

but the problem is:

IT's not working when one of the paths has a space in it

C:\My Documents <-will not work..

this drives me sad because i cant add some " in the code :)(

Share this post


Link to post
Share on other sites

ok: i want to copy the content (with all subdirs and trees and blah) of direcotry A to direcotry B

in unix:

cp -R /dummy/* /dummy2/

<{POST_SNAPBACK}>

like

Xcopy c:\dummy\*.* c:\dummy2 /s

or

Dircopy("c:\dummy" ,"c:\dummy2",1)


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

read above

<{POST_SNAPBACK}>

saw that after the post... however:

Dircopy("C:\My Documents\source" ,"C:\My Documents\target",1)

should work...

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

i did something like the runwait command too

$destination = StringFormat("%s",$instpath)
$source = StringFormat("%s\Server",$source)
$command = StringFormat("xcopy %s %s /E /M",$source,$destination)
RunWait($command)

but the problem is:

IT's not working when one of the paths has a space in it

C:\My Documents <-will not work..

this drives me sad because i cant add some " in the code :)(

<{POST_SNAPBACK}>

if something doesn't work because it has a space in the path, what do you do? put quotes around it. It has to do with FAQ 7

I don't know what you're doing with the string format, but here's how I'd do it...

runwait( @comspec & ' /c xcopy "' & $source &  '" "' & $destination & '" /E /M')

that will put double quotes around the souce and the destination.


"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

damn thank ya!

i was looking for this the hole day :)

but search for (") didn't match

Share this post


Link to post
Share on other sites

saw that after the post...  however:

Dircopy("C:\My Documents\source" ,"C:\My Documents\target",1)

should work...

<{POST_SNAPBACK}>

being as I'm to lazy to test, I believe that would result in "c:\my documents\target\source" not the contects of \source within target directly...

"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

being as I'm to lazy to test, I believe that would result in "c:\my documents\target\source" not the contects of \source within target directly...

<{POST_SNAPBACK}>

don't think so.... :)

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

don't think so.... :)

<{POST_SNAPBACK}>

damn. why do I even try? you're right. though, if the destination exists, even if it's empty, you need the 1

"I'm not even supposed to be here today!" -Dante (Hicks)

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  
Followers 0