Delete individual file when few (or all files) are selected

Here you can propose new features, make suggestions etc.

Moderators: Hacker, petermad, Stefan2, white

StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Post by *StatusQuo »

eugensyl wrote:%COMSPEC% /C del "%N%M"
Ah, I see the problem. To use those TC-internal variables in an external batch file, the have to be specified as parameters for the button you'd like to create. So they get passed to the batch file. E.g.:

Code: Select all

Command: 
FILENAME.BAT

Parameter: 
%P%N
In a batch file you can use those parameters as %1 (for first parameter) up to %9 (being the 9th parameter). In the above case there will only be %1, containing the file name including the complete path to it.
=> So all you have to do is define the button as shown above, then in the batch file replace every %N %M and their quotation marks with %1:

Code: Select all

   @echo off
   echo Now, you will delete permanently the file under cursor:
   echo %1
   echo.
   echo Press Ctrl-Break or Ctrl-C if this action is a mistake.
   pause
   del %1
   if exist %1 goto z
   echo The file under cursor was deleted.
   goto final
:z
   echo The file under cursor was NOT deleted.
:final
   pause
Ctrl-Break doesn't work here on my system, but Ctrl-C does (tested in Win2k SP4). Please try this with a non-important file first, which can be deleted...


But your example can also be solved without an external file. Just enter the settings for the button like this (tested with an entry in start menu, because I don't have/use any butons):

Code: Select all

Command: 
%COMSPEC% /c

Parameter: 
echo Now, you will delete permanently the file under cursor:&echo %P%N&echo.&echo Press Ctrl-C if this action is a mistake.&pause&del %P%N&echo.&(if not exist %P%N echo File was deleted.)&(if exist %P%N echo File was NOT deleted.)&pause
(The text for "Parameter" is one single line without line breaks.)

Ctrl-Break doesn't work here on my system, but Ctrl-C does (tested in Win2k SP4). Please try this with a non-important file first, which can be deleted...
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
User avatar
eugensyl
Power Member
Power Member
Posts: 564
Joined: 2004-06-03, 18:27 UTC
Location: România
Contact:

Post by *eugensyl »

StatusQuo wrote:
eugensyl wrote:%COMSPEC% /C del "%N%M"
Ah, I see the problem....[/b]
Thank you. I have tried. It's work both. But...
I DO NOT RECOMMEND THIS!

First option delete first file selected from the list and the second remove selection (not the files).
It's useless.
The aim for this topic is to keep the selection until a single file is deleted WITH CONFIRMATION with a special advanced function, I mean.
As I sad a good shortcut can be CTRL+DEL (available).
Also, default option must be cancel button "NO" and/or ESC.

Anyway, thank you again.
My Best Wishes,

Eugen
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Post by *StatusQuo »

eugensyl wrote:First option delete first file selected from the list and the second remove selection (not the files).
It's useless.
Sorry to hear that, because both versions work fine here. :?: (Win2k SP4, but IMHO this shouldn't matter here.)

Both versions remove the selection, that's true. But to easily restore the previous selection you just need to e.g.
- make a second button with command cm_RestoreSelection (or press "/" key on numeric keypad, or use menu: Mark -> Restore Selection)
(I obviously missed to write that, sorry. :oops: )
So after setup it is two steps, e.g. pressing two buttons after each other, to delete the file under the cursor and then restore the selection.

If files other than the one under the cursor get deleted, then you maybe put the wrong parameters into the button setup?
Here are two screenshots of my working setup in start menu.
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
User avatar
eugensyl
Power Member
Power Member
Posts: 564
Joined: 2004-06-03, 18:27 UTC
Location: România
Contact:

Post by *eugensyl »

2StatusQuo

I believe you, of course.
If I know well, is a plugin written for more than one internal command.
With this you can do following action:

cm_SaveSelection
delete file under cursor (only with confirmation)
cm_RestoreSelection

It would be nice to have an internal command...

Thank you.
My Best Wishes,

Eugen
User avatar
eugensyl
Power Member
Power Member
Posts: 564
Joined: 2004-06-03, 18:27 UTC
Location: România
Contact:

Post by *eugensyl »

eugensyl wrote:2StatusQuo

cm_SaveSelection
delete file under cursor (only with confirmation)
cm_RestoreSelection
I made a button and work fine, without any risk.

This is:
TCMC 50 CM530 EMem_del_unique CM529

Where:
TCMC - small utility which accept multiple TC commands
em_del_unique is CMD (or BAT) file above as external command


It would be nice to have an internal command unique...
My Best Wishes,

Eugen
Post Reply