Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

TCC v12.10 COPY /F does not work

May
22
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
 
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.
 
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:

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.)
 
(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?
 
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
 
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
 
>(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
 
>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
 

Similar threads

Back
Top