Button to delete the current folder

Does the following work better?

Go UP BACK

I'm getting closer. This works

[code]@set mypath {sourcepath|nopath|noterm}

Go UP

Select {$mypath}[/code]

But this doesn't work!

[code]@set mypath {sourcepath|nopath|noterm}

Copy MOVE TO ..
Go UP

Select {$mypath}[/code]

As soon as I add the Copy MOVE TO .. it breaks it.

(See my last post above yours...)

Yes I saw that. That is a very bad command. For Go UP BACK to work, you consider entering the child folder through the parent. It works only that way because you use BACK and it restores selection.

But consider going to the folder from some place else than his parent using the tree view for example. In that case it does not work because the parent was not selected previously.

This has to work with Go UP. That is the only logical acceptable solution.

Finally, this works

[code]@set ChildPath={sourcepath$|noterm}
@runmode hide

Properties SETLABEL Important FILE *

Select ALL
Delete

Go ..

rmdir {$ChildPath}[/code]

This deletes all inside the folder and the folder itself and if the Tab is locked it still works.
This is perfect.

Now I want to make a version with Copy MOVE TO ..
Where it moves up the selected files and deletes everything and also work in a locked tab.

This is hard because as soon as I add Copy MOVE TO .., {$ChildPath} variable doesn't work anymore.

I've been using the following button for ages

@dirsonly @nodeselect Copy MOVE FILE {filepath$}* TO {filepath$|..} delete Select Next

It moves everything inside the selected folder up (even in Flatview to the corresponding folder) and deletes that folder. And if I put Go Up in the first line and remove @dirsonly it stil works but you have to select a file or folder first.

Try this:@set a={sourcepath|nopath|noterm} Go UP Select {$a} Delete

Thank you kundal. Your script is like mine and it works to delete an entire folder.

Now add Copy MOVE to your script and your script does not work anymore. Why is that?

[code]@set a={sourcepath|nopath|noterm}

Copy MOVE TO ..

Go UP
Select {$a}
Delete[/code]

Kundal, why the above script doesn't work?

Have you got anything selected when you run that? "Copy MOVE TO .." would only move the selected items, since nothing else is specified. If nothing is selected, that line would cause the command to fail.

Yes, some files are selected. As soon as you use Copy MOVE TO .. it's like it erases the variable.
{$a} has no value in it anymore when it reaches Select {$a}

This one moves the folder content to the parent folder and removes the empty folder. Working fine here.@set ChildPath={sourcepath$|noterm} @runmode hide Copy MOVE * TO .. Go .. rmdir {$ChildPath}

Thanks but not enough. I want only the selected files moved up and not all of them.

It has to work with Copy MOVE TO ..

This works for me:@set ChildPath={sourcepath$|noterm} Copy MOVE {file} TO .. Go .. Delete {$ChildPath}

Wow, Thank you so much kundal. It finally works. :thumbsup: I have been spending 3-4 days on this.

It seems the secret was in {file}. How come Copy MOVE TO .. doesn't work but Copy MOVE {file} TO .. works!?

When I use

[code]@set ChildPath={sourcepath|nopath|noterm}

Go UP

Select "{$ChildPath}"[/code]

Sometimes it works and some times it doesn't select.

What are the situations where Preferences / Folders / Folder Behaviour / Select previous folder when going Up doesn't work for you?

This code

@set ChildPath={sourcepath|nopath|noterm} Go UP Select "{$ChildPath}"

Does not work when there is spaces in the name of the folder.

if you are inside New_Folder (no spaces), it works.
if you are inside New Folder (with spaces), it does not work.

This code, removed "" from Select {$ChildPath}

@set ChildPath={sourcepath|nopath|noterm} Go UP Select {$ChildPath}

inside these folders
New Folder works
New Folder - Copy works
New Folder - Copy (4) DOES NOT WORK

Preferences / Folders / Folder Behaviour / Select previous folder when going Up
was disabled, I enabled it and now the same script works. I don't even need all that code anymore I can just use

Go UP

Maybe this issue needs to be looked into. That when you explicitly use a code to select a folder, it should select the folder, independent of what are the navigation settings.

There's no bug there, you needed to remove the extra set of quotes (which you worked out) and to add the EXACT argument to the Select command so wildcard characters like '(' and ')' are interpreted literally, which would fix the issue with "(4)" in the file path.

But that's moot if you can just turn the option on which Ric/DesertDwarf suggested earlier and then use a simple command without worrying about selection.