Jump to content

Recommended Posts

Posted

Hi all,

Dircopy copies only the contents of a directory passed to it. It simply copies its contents to another location, but fails to copy

the folder itself. how to overcome this?

Rgds,

kris

Posted

Hi all,

Dircopy copies only the contents of a directory passed to it. It simply copies its contents to another location, but fails to copy

the folder itself. how to overcome this?

Rgds,

kris

Works ok for me, post what you tried please.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Posted

Works ok for me, post what you tried please.

#RequireAdmin

$source = "c:\sip\"
$dest = "d:\hello\"

DirCopy($source,$dest,1)

Initially i thought it was copying the files inside the folder, but i just realised , that its not copying anythin.

Posted

Read the documentation. It's very clear on what the problem is.

well, it doesnt work eitherway, whether i have a trailing backslash or not.

#RequireAdmin

$source = "c:\sip"
$dest = "d:\sip\"

DirCopy($source,$dest)
Posted (edited)

well, it doesnt work eitherway, whether i have a trailing backslash or not.

#RequireAdmin

$source = "c:\sip"
$dest = "d:\sip[s]\[/s]"

DirCopy($source,$dest)
Does the source dir exist ?

Do you have a d drive ?

Does the dest dir exist ?, if so you need the overwrite flag

Edit - Just notice trailing backslash on $dest.

Edited by BigDod


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Posted

Does the source dir exist ?

Do you have a d drive ?

Does the dest dir exist ?, if so you need the overwrite flag

Edit - Just notice trailing backslash on $dest.

I am trying to copy a folder from c: drive to d: drive.

The source dir exits? ---yes.

do i have a d drive? ----ofcourse!

does the dest dir exit? no!

heres wht i see,

#RequireAdmin

$source = "c:\sip"
$dest = "d:\sip

DirCopy($source,$dest)

the destination sip directory does not exist. but when i run the above script, it creates a folder sip and copies the contents to it,

but that doesnt help me yet. what i want is when i dont have a "sip" folder in my d: drive, it must be created prior to getting copied. just like a normal windows way of copying a folder to another location.

and wht flags are you talking about ? i only see two of them , 0 and 1. am i missing somethin here?

Posted

the destination sip directory does not exist. but when i run the above script, it creates a folder sip and copies the contents to it,

but that doesnt help me yet. what i want is when i dont have a "sip" folder in my d: drive, it must be created prior to getting copied. just like a normal windows way of copying a folder to another location.

and wht flags are you talking about ? i only see two of them , 0 and 1. am i missing somethin here?

Reread what you have just written. You have just said what happen and what you want to happen but the way you have written makes both statements the same.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Posted

Did you refresh the explorer window for drive D: after the copy finished? Also this works with and without trailing slash.

Posted

Reread what you have just written. You have just said what happen and what you want to happen but the way you have written makes both statements the same.

BigDod,

apologies!! Heres my bit,

#RequireAdmin

$source = "c:\sip"
$dest = "d:\hello"

DirCopy($source,$dest)

Refer above code. note: destination folder "hello" does not exist.

what i am trying to acheive?: The "sip" folder must get copied as "d:\hello\sip" meaning, a folder called "sip" must be created

inside the "hello" folder and then the contents of the source "sip" folder must get copied to the destination "sip" folder.

Current behavior?: "hello" folder gets created. The contents of the sip folder gets copied to "hello".

what i actually want is "d:\hello\sip"... what i effectively get is "d:\hello"

hope am clear !

Posted

You should have said that to start with

#RequireAdmin

$source = "c:\sip"
$dest = "d:\hello\sip"

DirCopy($source,$dest)


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Posted

??????????

$source = "c:\sip"

$dest = "d:\hello\sip"

DirCopy($source,$dest)

In that case, it works, but my purpose is lost then. what happens in a case, where i dont knw what the source folder is?

so having $dest="d:\hello\sip" doesnt help me!

Posted

In that case, it works, but my purpose is lost then. what happens in a case, where i dont knw what the source folder is?

so having $dest="d:\hello\sip" doesnt help me!

How can you copy that which you do not know?

Posted

How can you copy that which you do not know?

Magic :D


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Posted

How can you copy that which you do not know?

ok, this is getting a little confusing now. sorry. heres the story.

This piece of code is part of a slightly bigger code that lets me upload my new builds to my client server.

my script has a gui browse button for both source and destination. now, when i click on the browse, it brings up my root directory and lets me select a folder...lets assume i select "c:\sip\sipchannel" thats the folder for source.

now lets say i select "\\vector\new_release\4.5" as the destination. when i go ahead and upload it, it copies the contents of

"sipchannel" to "\\vector\new_release\4.5", instead of "\\vector\new_release\4.5\sipchannel" .........makes sense?

Posted

The behavior is rather unintuitive. Assume the following source directory structure:

C:\Source\File.txt

What I expect to happen is this:

DirCopy("C:\Source", "C:\Dest")

Source is copied to Dest (current behavior) producing:

C:\Dest\File.txt

However, with:

DirCopy("C:\Source", "C:\Dest\")
I expect the following:

C:\Dest\Source\File.txt

The behavior, as the documentation says, is based off xcopy. I've always found xcopy a pain in the ass to use.

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
×
×
  • Create New...