PDA

View Full Version : Copying location ERROR


Kemp100
06-27-2002, 12:16 PM
I am trying to copy files from a FOLDER to another FOLDER..although a problem came up where one of the destination folder has a "+" in it..here is the situation

trying to copy all files from "C:\test\*" to "C:\test1\test+"

here is the Code(s) I have tried to use...

os.system(r"copy c:\test\* c:\test1\test+")

--OR--

os.system(r"copy c:\test\* "c:\test1\test+"")

What Do i need to do to get it working...

PLEASE HELP!!!!!!!!!

Strike
06-27-2002, 01:14 PM
I'm pretty sure python doesn't do globbing for you, meaning you can't use stuff like * to get filenames. You might have to build the file list and then pass in each argument.

jemfinch
06-27-2002, 02:34 PM
There's a glob module to do that.

But anyway, you shouldn't be using os.system. It's non-portable, and you're only using it to duplicate functionality Python already has. Take a look at the shutil module.

(Using os.system isn't writing Python; it's writing shell scripts (or batch files, as the case may be) with weird indentation.)

Jeremy

kmj
06-27-2002, 03:24 PM
I agree with jemfinch.

I think inkedmn already gave Kemp100 the appropriate code.