COPY query

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
May 29, 2008
61
0
#1
I hope the below are self-explanatory.
What am I not understanding about the copy command?
Is *2* "erroring out" (without error message) when the first sub-directory has nothing to copy?
Is so why no equivalent of /I in global?
How do I do what I want (copy all xxx*.* files from the tree, not creating empty directories)?

- Yakir

TCC 13.03.38 x64 Windows 7 [Version 6.1.7601]
(I get the same with ver. 12 on a different machine)

** 1 **
C:\yhWork\test-> dir /s/f/h
C:\yhWork\test\test01
C:\yhWork\test\test02
C:\yhWork\test\test01\ppp.qqq
C:\yhWork\test\test01\xxx.txt
C:\yhWork\test\test01\xxx2.txt
C:\yhWork\test\test02\yyy.zzz

C:\yhWork\test-> copy /s/f xxx*.* ..\test2
TCC: (Sys) The system cannot find the file specified.
"C:\yhWork\test\xxx*.*"
C:\yhWork\test\test01\xxx.txt => C:\yhWork\test2\test01\xxx.txt
C:\yhWork\test\test01\xxx2.txt => C:\yhWork\test2\test01\xxx2.txt
2 files copied

** 2 **
C:\yhWork\test-> dir /s/f/h
C:\yhWork\test\test01
C:\yhWork\test\test02
C:\yhWork\test\test01\ppp.qqq
C:\yhWork\test\test02\xxx.txt
C:\yhWork\test\test02\xxx2.txt
C:\yhWork\test\test02\yyy.zzz

C:\yhWork\test-> copy /s/f xxx*.* ..\test2
0 files copied
 
#5
The problem is in case *2* when no files are copied. Case *1* is OK!
That seems impossible UNLESS your "copy" command is an alias! No character that is legal in a filename is treated specially by TCC or by the Windows API it uses to copy.

I tested your command (using *copy to avoid biasing results by my COPY alias, below) on my system and it performed exactly as I expected. Without /e it warned that a specific directory had no files to copy, no error (warning) messages with /e. It copied all that matched. Tested with xxx*.*, xxx*1*.* and xxx*2*.* (always making the target directory empty before the test). In all instances the target directory contained exactly what I expected and what COPY reported. I

FYI, I do use an alias:
copy is an alias : *copy/[!descript.ion]/efgrhv/netj/j
where there is a redundancy: both /e and /ne are present, both have the same effect (historic reasons: older versions had only /e).
 
May 29, 2008
61
0
#6
Thanks for the feedback.

copy is not aliased

Here is how I set up the test:
> md test01
> md test02
then I copied some files into test01, including xxx*.* files
then I copied some files into test02, NOT including xxx*.* files
*1*: ran the copy command ==> all OK

Then copied the xxx*.* files manually from test01 to test02:
*2*: ran the copy command ==> 0 files copied !

i.e. it works if there are relevant file in the first (?!) directory, but not if there aren't


Just tried a further test, added test03

** 3**
C:\yhWork\test-> dir /s/f/h
C:\yhWork\test\test01
C:\yhWork\test\test02
C:\yhWork\test\test03
C:\yhWork\test\test01\ppp.qqq
C:\yhWork\test\test01\xxx.txt
C:\yhWork\test\test01\xxx2.txt
C:\yhWork\test\test02\yyy.zzz
C:\yhWork\test\test03\xxx1.txt

C:\yhWork\test-> copy /s/f/e XX*.* ..\test2
C:\yhWork\test\test01\xxx.txt => C:\yhWork\test2\test01\xxx.txt
C:\yhWork\test\test01\xxx2.txt => C:\yhWork\test2\test01\xxx2.txt
C:\yhWork\test\test03\xxx1.txt => C:\yhWork\test2\test03\xxx1.txt
3 files copied

** 4 **
C:\yhWork\test-> dir /s/f/h
C:\yhWork\test\test01
C:\yhWork\test\test02
C:\yhWork\test\test03
C:\yhWork\test\test01\ppp.qqq
C:\yhWork\test\test02\xxx.txt
C:\yhWork\test\test02\xxx2.txt
C:\yhWork\test\test02\yyy.zzz
C:\yhWork\test\test03\xxx1.txt

C:\yhWork\test-> copy /s/f/e XX*.* ..\test2
0 files copied !!!!!!!!!!!!!!!
(there goes my theory that the empty dir is "erroring out")

This is looking more and more like a case where I will slap my forehead when I see what is happening :-(
 
May 29, 2008
61
0
#8
C:\yhWork\test-> attrib /d test02
____D_________ C:\yhWork\test\test02

C:\yhWork\test-> attrib /d test01
____D_________ C:\yhWork\test\test01
 

rconn

Administrator
Staff member
May 14, 2008
10,103
85
#9
I couldn't reproduce this the first couple of times I tried it, but after trying on a couple of other machines I was eventually able to recreate it. It turns out to be a Windows API (I can only reproduce it on Win7 x64 so far) that's behaving erratically, albeit in a fashion that's somewhat murky in the documentation.

At any rate, I have a workaround for 13.03.39, which I will upload in the next day.