problems with system("copy");


#1

Ho,

i try the following

string $source = “c:/test/test.jpg”;
string $dest = “c:/damn/”;
system (“copy “” + $source + “” " + “”” + $dest + “”");

but it dont work .

fif anyone know why? …

if i change the path from c:/test/test.jpg int c:\ est\ est.jpg it works … so maybe it is possible to convert the path –


#2

Yes.

First, DOS doesn’t use forward slashes. You can use forward slashes to define paths for MEL because Maya converts them internally as needed. But with the system command, you are speaking directly to DOS so you have to use it’s syntax.

Second, in order to define a backslash within a string in MEL, you have escape that character. The backslash IS the special chracter used by MEL to escape other characters as you have done with the " character. This is why specifying “\” will work.

-jl


#3

Originally posted by X-Tender
… so maybe it is possible to convert the path –

It is, check out toNativePath command.


#4

Wohoo … it works :stuck_out_tongue:


#5

Hi !

I have a problem too, but only when i have a “space” in
my destination directory which is “Program Files” ,
Otherwise everything works well !

Any clue ?


#6

You can specify DOS paths that include a space by encasing the entire path in quotes like so:

““c:\my crazy name\folder””

-jl


#7

Many thanks bigfatMELon !
it works !:slight_smile:


#8

You can also escape the spaces:

“c:\my\ crazy\ name\folder”

– Mark


#9

Thank you Mark !


#10

Ooookay i need a lil help right now… this is me :banghead: …I’m trying to run smedge from the system command this is my command line system(“c:\Program\ Files\smedge\smedge.exe”);

and this is my result…

Result: ‘C:\Program’ is not recognized as an internal or external command,

what gives?

Thanks all I read your book Mark…and aside from this lil hiccup it’s made mel very useful for me Kuddos my man.


#11

Replace

system(“c:\Program\ Files\smedge\smedge.exe”);

with

system("“c:\Program\ Files\smedge\smedge.exe”");

or

system("“c:\Program Files\smedge\smedge.exe”");

or

system(“c:\Progra~1\smedge\smedge.exe”);

The ~1 thing is a throwback to the old 8.3 naming standard. If you want, dir /x will give you the 8.3 equivalent to the long file name.


#12

Thank ya sir! workin like a charm :wink:


#13

Hi,

you can also use Maya melcommand sysFile, instead of the system command… :slight_smile:

e.g. like this… -->


string $source = "c:/test/test.jpg";
string $dest = "c:/damn/";
 
sysFile -copy $dest $source;

regards

Alex


#14

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.