Button to delete the current folder

I have made a button to delete the current folder. Here it is:
Select ALL
Delete
Delete FILE .
Go ..

The problem is that if the folder is empty, it doesn't delete the folder.
How can I make it to work in that case also? Why it stops at Delete FILE . ?

I don't want to just use
Delete FILE .
Go ..

I would like to keep the Select ALL command if possible for visual and security reasons.

You can't delete the folder you're currently in because it's in use. You have to leave the folder before you delete it, not after.

See here: Copying, Moving, Renaming, Deleting current folder

Well, no, actually you can delete the folder you're currently in. This works perfectly well. Try it.
Delete FILE .

It deletes the folder you're currently in.

Oh, you're right. :slight_smile:

I think the first button is failing because when there are no files the first Delete commands has nothing to work on so it cancels the button.

This seems to work and I think is all you need:

Select All Delete .

The Select All command there is purely cosmetic and could be removed. It has no effect on what's deleted and is just there to visually highlight all the things about to be deleted, as per your post.

You don't seem to need the Go UP at all, BTW. Opus automatically goes up if the current folder is deleted.

(I've updated the post I linked to as well. Just using "Delete ." is much better than the previous versions. I think that may not have worked in the past but it works now. Thanks for pointing it out. :slight_smile: )

Thank a lot. Yes that's so simple and elegant. Why didn't I think of it! :smiley:

I want to complete this excellent code

Select All Delete .

by changing the status of the selected files to important to give a better visual warning before deleting the folder.

I spent some time reading but couldn't find. Can you please tell me how can you change the status of a file by a command?

Select All Properties SETLABEL Important Show VIEWERCMD=refresh Delete .

I added Properties SETLABEL Important
The problem is that you dont see the status change, you need a refresh
I added Show VIEWERCMD=refresh

The problem now is that it breaks the Delete . command and it no longer asks you for folder deletion.

Select All Properties SETLABEL Important Go REFRESH Delete .

Works now!

(Show VIEWERCMD=refresh refreshes the image viewer.)

In general, you don't have to refresh to see label changes, but Opus waits until the end of the command to show the change, so you do need to if you want to see the change in the middle.

If you're only selecting things for the Properties command, you don't need to:

Properties SETLABEL Important FILE * Go REFRESH Delete .

If you want the files selected after the refresh, try this:

Properties SETLABEL Important FILE * Go REFRESH Select ALL Delete .

Thanks

Tried both scripts and there is a problem with them.

If the tab is unlocked, everything works correctly.

If the tab is locked (allow folder changes). It deletes the files but the viewer freezes and doesn't show the change. You have to refresh and in that case it gives an error and you have to click go to parent.

Could you please give a script that works with locked (allow folder changes) tabs too?

I'm inside a folder and want to delete it. A visual warning before deleting would be necessary.

You could add a command to unlock the tab.

But I don't want to do that because I will lose the base of the folder tree where I locked it.
Or can I lock it again with the same base folder?

And that doesn't seem like a proper solution. I don't know if it's a bug with dopus or the script is not clean.
What's a proper script for this?

Maybe if it can give a user generated message and then if clicked OK, it can go up one level and then delete the selected folder.
Can we create user messages?

Aren't you deleting the tab's folder?

I'm deleting the current folder only, the tab should stay and go to the parent.

folder parent.

This must be really simple but I have spent several hours already with no success. It's as simple as

Select ALL
Delete
Go UP

Now I need to Select the parent and delete and I can't. tried

@set ChildPath={sourcepath|nopath|noterm}

Select ALL
Delete
Go UP

Select {$ChildPath}

doesn't work, nothing selected. How can you debug in the simple scripting?
I need to see the value of {$ChildPath}. Tried Clipoboad SET, nothing works.

Wow, not one person here knows?

When you

Go UP

How to select the folder we just exited?
Select ??????

Preferences / Folders / Folder Behaviour / Select previous folder when going Up

Nope. I have already done that. This has nothing to do with that. That is for your manual navigation.

We are talking about programming, scripting. In script when you use Go UP the folder is not selected even if you have that option on. try it, it's easy to try.