Author Topic: Can't get MC.Filesystem.Delete to work  (Read 19676 times)

Ulfhednar

  • Contributor
  • VIP Member
  • *****
  • Posts: 514
    • View Profile
Can't get MC.Filesystem.Delete to work
« on: July 28, 2022, 18:02:16 »
So I have a user defined command attached to a button:-
Code: [Select]
MC.Filesystem.Delete FILTER="*.zip; *.rar"But it won't work & I get no error or dialog of any kind.
I've assumed I can only use one command in a button of this type, not multiple as with a script, so I haven't added a select option first, I get the same result with files pre-selected or unselected.
What have I missed.....?   :-\
 

AlanJB

  • VIP Member
  • *****
  • Posts: 436
  • VERY old Programmer
    • View Profile
Re: Can't get MC.Filesystem.Delete to work
« Reply #1 on: July 28, 2022, 19:55:38 »
Hi Ulf.

Version?

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4416
    • View Profile
    • Multi Commander
Re: Can't get MC.Filesystem.Delete to work
« Reply #2 on: July 29, 2022, 09:34:20 »
Yes
MC.Filesystem.Delete is disabled. It had some issue.
Also the Filter option was removed.. The Normal Delete dialog had a filter box. but there are so many situation where it did not works well. so it was removed.. Might be why MC.Filesystem.Delete was disabled.
It was long time ago.. lots have happen since then. I will put it on my list and see if it is possible to add it again


Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4416
    • View Profile
    • Multi Commander
Re: Can't get MC.Filesystem.Delete to work
« Reply #3 on: July 29, 2022, 13:33:30 »
I took a quick look and it was almost working. But I changed it a bit

So in next beta release this should work.

However if you do not specify a PATH you must specify a USE_CURRENT_SOURCEITEM parameter instead, this will take current source item that are in focus and use as PATH.
It was prone to accidental delete of files without specifying that you really want to do that.
Delete to recycle bin are not yet support and will have to wait. So it is still a bit risky to use since you get no UI or confirmation with the MC.FileSystem. methods. They go directly to the filesystem layer.
MC.Explorer.Delete access Delete via the UI layer. and you can see UI.

Application Log and FileOperation Log will output error and what is deleted.
« Last Edit: July 29, 2022, 13:43:31 by Mathias (Author) »

Ulfhednar

  • Contributor
  • VIP Member
  • *****
  • Posts: 514
    • View Profile
Re: Can't get MC.Filesystem.Delete to work
« Reply #4 on: July 29, 2022, 14:00:34 »
Thanks for the replies.
I am relieved that I haven't gone completely mad ...even if I did forget to add the build #!   ::) ;D

Thanks for the details Mathias, hopefully the USE_CURRENT_SOURCEITEM parameter will do what I need.  It certainly looks like a good solution.
I will have to run a few tests on dummy files first but if it is being logged it should be OK.

....I always wanted to try juggling hand-grenades so this will be a step in the right direction.   ;)

Ulfhednar

  • Contributor
  • VIP Member
  • *****
  • Posts: 514
    • View Profile
Re: Can't get MC.Filesystem.Delete to work
« Reply #5 on: July 30, 2022, 13:13:03 »
Thanks for trying to make this function work Mathias.
I have just attempted to use this command.
I get Failed to volume item whenever I use it.
I've tried :-
Code: [Select]
MC.Filesystem.Delete USE_CURRENT_SOURCEITEM FILTER="*.zip; *.rar"
MC.Filesystem.Delete USE_CURRENT_SOURCEITEM "*.zip; *.rar"
MC.Filesystem.Delete USE_CURRENT_SOURCEITEM="*.zip; *.rar"

It does appear to try to action the command, but even with files selected doesn't like something & always gives that error.  ???

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4416
    • View Profile
    • Multi Commander
Re: Can't get MC.Filesystem.Delete to work
« Reply #6 on: July 30, 2022, 13:18:02 »
Thanks for trying to make this function work Mathias.
I have just attempted to use this command.
I get Failed to volume item whenever I use it.
I've tried :-
Code: [Select]
MC.Filesystem.Delete USE_CURRENT_SOURCEITEM FILTER="*.zip; *.rar"
MC.Filesystem.Delete USE_CURRENT_SOURCEITEM "*.zip; *.rar"
MC.Filesystem.Delete USE_CURRENT_SOURCEITEM="*.zip; *.rar"

It does appear to try to action the command, but even with files selected doesn't like something & always gives that error.  ???

It is the first alternative. filter must be set to the "FILTER" option and the item in focus must be a folder.
Where is the files located ? normal harddrive ?  or a virtual path ?

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4416
    • View Profile
    • Multi Commander
Re: Can't get MC.Filesystem.Delete to work
« Reply #7 on: July 30, 2022, 13:24:36 »
Thanks for trying to make this function work Mathias.
I have just attempted to use this command.
I get Failed to volume item whenever I use it.
I've tried :-
Code: [Select]
MC.Filesystem.Delete USE_CURRENT_SOURCEITEM FILTER="*.zip; *.rar"
MC.Filesystem.Delete USE_CURRENT_SOURCEITEM "*.zip; *.rar"
MC.Filesystem.Delete USE_CURRENT_SOURCEITEM="*.zip; *.rar"

It does appear to try to action the command, but even with files selected doesn't like something & always gives that error.  ???

I have this

E:\Test\Test and in that folder I have

testfile.png
testfile.rar
testfile.zip

I'm showing the content of E:\test and focus in on 'test' folder ( E:\test\test )

I run the command
and it deleted all files in text except the *.png file.


Ulfhednar

  • Contributor
  • VIP Member
  • *****
  • Posts: 514
    • View Profile
Re: Can't get MC.Filesystem.Delete to work
« Reply #8 on: July 30, 2022, 16:03:22 »
Well thanks for the fun Mathias!  ;)
You got me twice,
1. because I was using the earlier release without the updated function
2. it killed <20 files it found in the directory above the focused one.

No problem as I was able to recover them.  Only lost a zip with all my crypto-currency addresses, but what's $1.6m between friends....   ;D  :P
 ...A few more tests will be needed I think!

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4416
    • View Profile
    • Multi Commander
Re: Can't get MC.Filesystem.Delete to work
« Reply #9 on: July 30, 2022, 16:49:13 »
Well thanks for the fun Mathias!  ;)
You got me twice,
1. because I was using the earlier release without the updated function
2. it killed <20 files it found in the directory above the focused one.

No problem as I was able to recover them.  Only lost a zip with all my crypto-currency addresses, but what's $1.6m between friends....   ;D  :P
 ...A few more tests will be needed I think!

1. first version was missing some logging that was not included in the release. I also improved how it handled filters and if the path is pointing to file instead and folder..

2. USE_CURRENT_SOURCEITEM take the item that are in focus from the panel that are in focus (source panel). but it is important that the correct panel is active.. so it picks correct.
it should not pick a folder above.. it picks the one that is on focus. that the line marker is on..

Hmm Might be to dangerous function to allow delete so easy. Maybe should require a confirmation box. ?  maybe a "Do you really want to delete : <folder> ?" box ?, but the idea with script it to not have them..


« Last Edit: July 30, 2022, 16:58:01 by Mathias (Author) »

AlanJB

  • VIP Member
  • *****
  • Posts: 436
  • VERY old Programmer
    • View Profile
Re: Can't get MC.Filesystem.Delete to work
« Reply #10 on: July 30, 2022, 18:06:51 »
Hmm Might be to dangerous function to allow delete so easy. Maybe should require a confirmation box. ?  maybe a "Do you really want to delete : <folder> ?" box ?, but the idea with script it to not have them..

@Mathias, just a thought...

You could offer the dialog by default with a "Do you really want to delete : <folder> ?" but include an optional NODIALOG parameter (similar to the Multiscript function CopyFile).

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4416
    • View Profile
    • Multi Commander
Re: Can't get MC.Filesystem.Delete to work
« Reply #11 on: July 30, 2022, 18:27:30 »
Hmm Might be to dangerous function to allow delete so easy. Maybe should require a confirmation box. ?  maybe a "Do you really want to delete : <folder> ?" box ?, but the idea with script it to not have them..

@Mathias, just a thought...

You could offer the dialog by default with a "Do you really want to delete : <folder> ?" but include an optional NODIALOG parameter (similar to the Multiscript function CopyFile).
Yes i was thinking that. problem is that MC.Explorer.Delete is really the one to use if you want a dialog. Problem is that it does not support filter.
MC.FileSystem.Delete goes directly to the filesystem layer, and should not show a UI..  But might break that principle with this, fell that it is to dangerous to not show a warning by default.


Ulfhednar

  • Contributor
  • VIP Member
  • *****
  • Posts: 514
    • View Profile
Re: Can't get MC.Filesystem.Delete to work
« Reply #12 on: July 31, 2022, 17:20:24 »
Tried this again experimentally
D:\test1\test2\
was focus
I added 6 dummy files incl 1 zip & 1 rar to test2, used :-
Code: [Select]
MC.Filesystem.Delete USE_CURRENT_SOURCEITEM FILTER="*.zip; *.rar"
Log output
Code: [Select]
2022-07-31 15:43:36.274 MC.FileSystem.Delete : Parameter USE_CURRENT_SOURCEITEM set. Use current source item as PATH parameter : 'D:\test1\test2\..'
2022-07-31 15:43:36.274 MC.FileSystem.Delete : Scanning folder..
2022-07-31 15:43:36.274 MC.FileSystem.Delete : Found 8 items in path
2022-07-31 15:43:36.274 MC.FileSystem.Delete : 2 Filters found
D:\test1\test2\
was focus again
I added 1 zip & 1 rar to both test1 & test2 & ran button, all were deleted, re item count:-
Code: [Select]
2022-07-31 15:47:22.824 MC.FileSystem.Delete : Parameter USE_CURRENT_SOURCEITEM set. Use current source item as PATH parameter : 'D:\test1\test2\..'
2022-07-31 15:47:22.824 MC.FileSystem.Delete : Scanning folder..
2022-07-31 15:47:22.824 MC.FileSystem.Delete : Found 10 items in path
2022-07-31 15:47:22.824 MC.FileSystem.Delete : 2 Filters found

So I added test3 folder
D:\test1\test2\test3\
Added 2 archives to each test folder: -
With test3 in focus, archives in test 2 & test 3 were deleted
With test2 in focus, only archives in test 3 were deleted, not in 1 or 2  ???

Log shows the command thinks I am in test3 (ran this 3 times with same result, it can't tell my focus is ..\test2\
Code: [Select]
2022-07-31 16:13:51.481 MC.FileSystem.Delete : Parameter USE_CURRENT_SOURCEITEM set. Use current source item as PATH parameter : 'D:\test1\test2\test3'
2022-07-31 16:13:51.481 MC.FileSystem.Delete : Scanning folder..
2022-07-31 16:13:51.481 MC.FileSystem.Delete : Found 5 items in path
2022-07-31 16:13:51.481 MC.FileSystem.Delete : 2 Filters found
So quite interesting...! 

A dialog could be helpful but only if the reason why the command includes other folders in such a surprising way gets caught.  Would adding FILTER to MC.Explorer.Delete be easier?
 
But in any case, don't let this ruin your summer Mathias.  ;)

AlanJB

  • VIP Member
  • *****
  • Posts: 436
  • VERY old Programmer
    • View Profile
Re: Can't get MC.Filesystem.Delete to work
« Reply #13 on: August 01, 2022, 12:50:18 »
A dialog could be helpful but only if the reason why the command includes other folders in such a surprising way gets caught.  Would adding FILTER to MC.Explorer.Delete be easier?

Now that is a good idea :D

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4416
    • View Profile
    • Multi Commander
Re: Can't get MC.Filesystem.Delete to work
« Reply #14 on: August 02, 2022, 10:55:03 »
A dialog could be helpful but only if the reason why the command includes other folders in such a surprising way gets caught.  Would adding FILTER to MC.Explorer.Delete be easier?

Adding support for Filter for for normal delete is planned but that is way more complex because that operation in done in a different way that support so much more

Somethings that I dont get..  is that if C:\Text1\test2 is current item in focus.. and you use USE_CURRENT_SOURCEITEM.  How you get D:\test1\test2\..  because ".." is only available if you are located INSIDE test2, When set test2 as item in focus then you are standing in Test1 folder. The only reason I can see this happening is that panel that are in focus is the other panel.. and you are showing the content of test2 and the focus item in that panel is the ".." item.

However ".." should not be possible to select.. I will block that.. if focus is on ".." it should not continue. else it will scan up the tree..

« Last Edit: August 02, 2022, 11:04:49 by Mathias (Author) »

Ulfhednar

  • Contributor
  • VIP Member
  • *****
  • Posts: 514
    • View Profile
Re: Can't get MC.Filesystem.Delete to work
« Reply #15 on: August 03, 2022, 11:56:17 »
Thanks for the reply Mathias.
FILTER to MC.Explorer.Delete = more complex - I see, just wondered ;)

CMD Reading different dirs:
I repeated this test multiple times because its results are so odd.
Opposite pane was different drive not just different dir...
Whilst wondering why I tried clicking on different areas of the pane before calling the cmd, eg <-... at top; lower empty space; different files/filetypes.
Each time as you can see from the item count it looked at other dirs both above & below. 
Maybe I'll try with more dirs & see where it jumps...

Anyway if you can force a scope lockdown that would solve it, even if it does not explain it :)


Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4416
    • View Profile
    • Multi Commander
Re: Can't get MC.Filesystem.Delete to work
« Reply #16 on: August 03, 2022, 12:44:54 »
Thanks for the reply Mathias.
FILTER to MC.Explorer.Delete = more complex - I see, just wondered ;)

CMD Reading different dirs:
I repeated this test multiple times because its results are so odd.
Opposite pane was different drive not just different dir...
Whilst wondering why I tried clicking on different areas of the pane before calling the cmd, eg <-... at top; lower empty space; different files/filetypes.
Each time as you can see from the item count it looked at other dirs both above & below. 
Maybe I'll try with more dirs & see where it jumps...

Anyway if you can force a scope lockdown that would solve it, even if it does not explain it :)

Don't really understand..  the folder is also included in the item count..  if you stand on test2 and run cmd..  test2, test2\file1.txt, test2\file2.txt  would be included. so 3. but then some of them would be filtered away

If the command is a normal "Custom command" type.. then you can not click while script is running. since it blocks the UI while running.

I find no issue except that you can run the command on ".."


« Last Edit: August 03, 2022, 12:47:34 by Mathias (Author) »

Ulfhednar

  • Contributor
  • VIP Member
  • *****
  • Posts: 514
    • View Profile
Re: Can't get MC.Filesystem.Delete to work
« Reply #17 on: August 05, 2022, 16:27:43 »
Yes I think we're saying the same thing. (But I'm not as clever as you  ;D  )

I was trying to give example that showed its' count included items external to the selected dir... & so
Quote
you can run the command on ".."