Welcome!

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

SignUp Now!

Deleting

Aug
168
4
I have a "prune" alias that's defined as follows:

prune=del /e /s /t /x /y /z /r /nnt

It's deleting significantly more than I expect as shown in the following output log. I had a few directories named "OptiTemp0", "OptiTemp1", and so forth, which I expected to delete with a simple "prune optitemp*" command. Look what I got instead:

C:\Users\JWILLI~1\AppData\Local\Temp> prune optitemp*
Removing C:\Users\JWILLI~1\AppData\Local\Temp\1jf3d0vi.rk5\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\Adobe\Acrobat\10.0\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\Adobe\Acrobat\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\Adobe\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\Microsoft Visual C++ 2010 x64 Redistributable Setup_10.0.30319\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\Microsoft Visual C++ 2010 x86 Redistributable Setup_10.0.30319\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\msohtmlclip\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\msohtmlclip1\02\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\OneNoteAttachments\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\OneNoteRuntimeCache\14.0\OneNoteRuntimeCache_Files\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\OptiTemp0\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\OptiTemp1\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\OptiTemp2\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\VBE\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\WPDNSE\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\{1212D1F7-FFD5-4527-9D15-5B95142CD8CB}\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\{40e9b1be-6b6d-4b04-884e-4cbb42134bbd}\
0 files deleted 4,096 bytes freed

I do not understand why it didn't delete the folder named "OptiTemp3", though it did delete the other three you see in the output. Nor do I understand why it did delete all kinds of folders that clearly don't match the pattern I specified.

Am I missing the obvious or is this thing not working properly? Thanks!
 
Remember that the wildcard is matching the names of files to delete, not directories to search into....
 
Remember that the wildcard is matching the names of files to delete, not directories to search into....

Now that makes sense. I guess I was thinking that the delete command would match the names of directories too. Is there any sort of deletion command that matches against both file and folder names? I'll go looking through the help to see what I can find now that you've acquainted me with that distinction. Thanks!
 
Way off topic ... I had complained about HTLM not rendering in Agent when I read emails from the forums. Nearly all the time they won't size horizontally properly (I get horizontal scroll bars). This post, by Phileosophos, is an exception; it sizes perfectly to fit in my usual Agent pane. What's the difference?

I have a "prune" alias that's defined as follows:

prune=del /e /s /t /x /y /z /r /nnt

It's deleting significantly more than I expect as shown in the following output log. I had a few directories named "OptiTemp0", "OptiTemp1", and so forth, which I expected to delete with a simple "prune optitemp*" command. Look what I got instead:

C:\Users\JWILLI~1\AppData\Local\Temp> prune optitemp*
Removing C:\Users\JWILLI~1\AppData\Local\Temp\1jf3d0vi.rk5\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\Adobe\Acrobat\10.0\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\Adobe\Acrobat\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\Adobe\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\Microsoft Visual C++ 2010 x64 Redistributable Setup_10.0.30319\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\Microsoft Visual C++ 2010 x86 Redistributable Setup_10.0.30319\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\msohtmlclip\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\msohtmlclip1\02\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\OneNoteAttachments\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\OneNoteRuntimeCache\14.0\OneNoteRuntimeCache_Files\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\OptiTemp0\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\OptiTemp1\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\OptiTemp2\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\VBE\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\WPDNSE\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\{1212D1F7-FFD5-4527-9D15-5B95142CD8CB}\
Removing C:\Users\JWILLI~1\AppData\Local\Temp\{40e9b1be-6b6d-4b04-884e-4cbb42134bbd}\
0 files deleted 4,096 bytes freed

I do not understand why it didn't delete the folder named "OptiTemp3", though it did delete the other three you see in the output. Nor do I understand why it did delete all kinds of folders that clearly don't match the pattern I specified.

Am I missing the obvious or is this thing not working properly? Thanks!
 
What's the difference?

It's not in a CODE or HTML bracket; it's just formatted text. In a CODE or HTML bracket there is no wordwrap, whereas in formatted text it can still wordwrap.
 
Why not something of the form:

for /a:d /h %fldr in ("optitemp*")prune "%fldr"
 
Thanks for the suggestion, Charles G. I have tried to operate with a simple, single alias to blow away files or folders based on a given spec. I thought that's what the del command did, but apparently I don't understand it correctly. The interesting thing is that using "del /e /s x optitemp*" deletes exactly the directories I expect and only the directories I expect, nothing else. I don't understand why adding the other arguments makes it ignore directories and go after files only, but maybe I will as I keep reading and re-reading the help.
 
Would you call the <whatever the answer is> the same way and expect it to remove either files andf/or folders? If you wanted to remove entire folders based on a specific parameter you could define:

PruneDirs=if "%1" NE "" for /a:d /h %fldr in ("%1")prune "%fldr"

PruneFilles=IN "%1" del /a:-d /s "%2"

IN=pushd %@full[%1] ^ pushd %@left[2,%@full[%1]] ^ %2& ^ popd ^ popd
 
Yeah, the point of my alias was so I didn't have to worry about whether I was working with files or folders. I could simply call "prune abc*" and be certain that all files that matched and all folders that matched were gone. Perhaps that's an unrealistic expectation on my part, but the help for the del command made it sound like I could pass file names or folder names without much concern.
 
Prompt> PruneBoth optitemp*

If you want it to remove both folders matching "optitemp*" as well files in the current folder matching the same "optitemp*" then you can combine the two aliases I said above - like this:

NOTE: CommandSeperator is ^

PruneBoth=@iif( "%1" NE "" ( for /a:d /h %fldr in ("%1")prune "%fldr" ^ del /a:-d /s "%1" ),ECHOERR PruneBoth: Nothing passed, nothing done.)
 
Back
Top
[FOX] Ultimate Translator
Translate