in reply to Re: Remove Read-Only using xcopy
in thread Remove Read-Only using xcopy

Thanks for the tip, but it still didn't copy the file =(. The only feedback I get is "0 File(s) copied" before the script continues to run (and crashes when it can't find the copied file). I debugged the two variables right before the function call and they contained the correct values. This one line of code is the only change to the script, which worked for weeks until the read-only problem showed up. Still stumped as to why it doesn't copy while the manually typed command does.

Replies are listed 'Best First'.
Re^3: Remove Read-Only using xcopy
by VinsWorldcom (Prior) on Jun 15, 2009 at 20:20 UTC
    Do you have a backslash between the drive letter and your first directory (d:\basedir ...). In your example, you don't and when I try xcopy without that slash, I get "0 files copied). When I put the slash in, it works.

    {C} > ls Directory of C:\Documents and Settings\Administrator\My Documents\tmp [.] [..] test.txt 1 File(s) 0 bytes {C} > xcopy "c:Documents and Settings\Administrator\My Documents\tmp\t +est.txt" "c:Documents and Settings\Administrator\My Documents\tmp\foo +\" File not found - test.txt 0 File(s) copied {C} > xcopy "c:\Documents and Settings\Administrator\My Documents\tmp\ +test.txt" "c:\Documents and Settings\Administrator\My Documents\tmp\f +oo\" C:\Documents and Settings\Administrator\My Documents\tmp\test.txt 1 File(s) copied {C} > ls Directory of C:\Documents and Settings\Administrator\My Documents\tmp [.] [..] [foo] test.txt 1 File(s) 0 bytes {C} > ls fool Directory of C:\Documents and Settings\Administrator\My Documents\tmp +\foo [.] [..] test.txt 1 File(s) 0 bytes
    Then using Perl:

    #!/usr/bin/perl use strict; my $und_db = "C:\\Documents and Settings\\Administrator\\My Documents\ +\tmp\\test.txt"; my $out_dir = "C:\\Documents and Settings\\Administrator\\My Documents +\\tmp\\foo"; system('xcopy', "\"$und_db\"", "\"$out_dir\\\"", '/r', '/y', '/i');
    And successful output:

    {C} > test C:\Documents and Settings\Administrator\My Documents\tmp\test.txt 1 File(s) copied {C} > ls foo Directory of C:\Documents and Settings\Administrator\My Documents\tmp +\foo [.] [..] test.txt 1 File(s) 0 bytes