1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

TCC v12.10 COPY /F does not work

Discussion in 'Support' started by NickCupery, May 30, 2011.

  1. NickCupery

    Joined:
    May 16, 2011
    Messages:
    22
    Likes Received:
    0
    I have not been able to get COPY to stop creating empty directories at the destination, even though I specify /F using the batch file shown here:

    Code:
    @REM                F:\BACKUP\TESTZERO.BTM             30-May-11   09:28:29am   
    @REM                ----------------------                                      
    @REM
    @REM -- Archives Drive D to folder \Drive_D\ on Drive J
    @REM -- Creates a bunch of empty directories, even though we specify /F
    @VER
    @COPY /B /E /K /M /S /F /X /Z    D:\*.*    %1:\Drive_D\  
    
    I formatted a USB thumb drive and plugged it in, where it became Drive J. Then I went to the folder containing TestZero.BTM, and typed "TestZero.BTM J". TCC then identified itself as v12.10 and then proceeded to create a gazillion empty folders on Drive J even though I told it not to via /F. <grrrr> Note that TCC did not copy any files at all, because none of the files on my Drive D has the Archive attribute set at this time. Perhaps that is key.

    -- Nick
     
  2. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,352
    Likes Received:
    39
    I don't know whether that constitutes a bug or not. (Does "empty" mean "containing no files," or does it mean "containing no files eligible to be copied"? The documentation is not clear.)

    But for cleanup purposes, you can remove all empty directories under C:\TARGETDIR with a command like:

    Code:
    del /s /e /x /y /q c:\targetdir\nul
    
    If there are no files at all in C:\TARGETDIR or any of its children or descendants, the above will remove C:\TARGETDIR itself -- this may or may not be what you want. You can prevent C:\TARGETDIR from being removed by doing a PUSHD C:\TARGETDIR before and a POPD after; TCC can't remove the current directory.
     
  3. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    10,022
    Likes Received:
    84
    You cannot use COPY /F that way. If you're doing conditional copies with a /S, COPY has to create the subdirectory first in order to do the test. And COPY cannot tell whether the source directory has more subdirectories (in which case it must create those subdirectories as well) until it has finished processing filenames and then looks for directories.

    The only way COPY could do this would be to convert it to a 2-pass system, which would be MUCH slower than the current approach. (And slower than doing the COPY and then doing a DEL /X of the empty directories.)
     
  4. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,352
    Likes Received:
    39
    This works, of course, but it's not very obvious. Would it make sense to have an option to RD, say RD /E, which recursively removes only empty directories from the inside out?
     
  5. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    From: rconn
    | The only way COPY could do this would be to convert it to a 2-pass
    | system, which would be MUCH slower than the current approach. (And
    | slower than doing the COPY and then doing a DEL /X of the empty
    | directories.)

    Since COPY followed by DEL is a 2-pass system, when performed manually, is there a reason why it could not be the implementation of the /F option, other than the issue of preexisting empty directories in the target, which remain empty?
    --
    Steve
     
  6. David Marcus

    Joined:
    Jun 4, 2008
    Messages:
    649
    Likes Received:
    1
    Definitely not obvious. At least it should be documented how to do this.
     
  7. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    From: Charles Dye
    | From: rconn
    || (And slower than doing the COPY and then doing a DEL /X of the empty
    || directories.)
    |
    | This works, of course, but it's not very obvious. Would it make sense
    | to have an option to RD, say RD /E, which recursively removes only
    | empty directories from the inside out?

    The command "*del/q/y/x/s/net/a:d" deletes all directory hierarchies which contain no files. There is no need to duplicate it via a new RMDIR option.
    --
    Steve
     
  8. David Marcus

    Joined:
    Jun 4, 2008
    Messages:
    649
    Likes Received:
    1
    That gives me a usage message. I need to put "nul" at the end.
     
  9. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,352
    Likes Received:
    39
    A Nathan Hale will work as well, since no files can match the /A:D. (Though I hate to rely on that; /A:D just seems wrong to me somehow.)
     
  10. NickCupery

    Joined:
    May 16, 2011
    Messages:
    22
    Likes Received:
    0
    >(Does "empty" mean "containing no files," or does it mean "containing no files eligible to be copied"? The documentation is not clear.)

    Eligibility is a source consideration; I want it to stop creating empty directories at the destination.

    The documentation is not clear? Here it is, verbatim, from the TCC v12.10 Help, via cut and paste:

    /F When used with /S, COPY will not create any empty subdirectories.

    What part of "will not create any empty subdirectories" are you claiming is unclear? I am an electrical engineer, not an English major, but I claim I can read real good. :-) Far as I am concerned, there ain't anything unclear about the claim. What it is, is FALSE.

    Thank you, Charles, for the one-liner to remove the empty directories after-the-fact, even though I would never use it (Del is way too dangerous). Besides, we should be talking about PREVENTING these things, not continually mopping them up.

    Hmmm, say, I've just now dreamed up a saying to cover this situation:

    "An ounce of prevention is worth a pound of cure".

    -- Nick
     
  11. NickCupery

    Joined:
    May 16, 2011
    Messages:
    22
    Likes Received:
    0
    >If you're doing conditional copies with a /S, COPY has to create the subdirectory first in order to do the test.

    The only thing conditional is at the source (does the source file have its Archive bit set?) This test in NO WAY requires first creating a destination path.



    >The only way COPY could do this would be to convert it to a 2-pass system

    Rex, it ain't 1981 anymore. :-) I am typing this on a 2nd gen Core i7 with 8 gigs of DRAM and an Intel SSD. This thing is so FAST it comes up with answers before I can type the questions! Anyway, on even my very slowest machine (a netbook with an Atom CPU), I don't care how many passes COPY makes in order to do the job right. It can take 17 passes if it likes, just so long as it does not create spurious directories.

    Here is how I would do it (in one pass): FindFirst/FindNext to get the next candidate, and check the eligibiity of said candidate. If eligible, optimistically COPY the file to the destination with a full path specification. If no error, be happy. If encounter "no such path" error, then create the path and then copy the file. Done.

    -- Nick
     

Share This Page