Moving files around via context menus

I already posted a button to move files into named folder, and putting all the contents in a parent directory. You can find the link here:

This time, I'll explain how to make user commands for these and implement them in contextual menus (in this case, I prefer user commands as the functions can be assigned from everywhere, and the day you have to change something, you only change the code once).

So here we go.

First, let's create the user commands that we will need:
Go to Settings -> Customize
In the command tab, go to "user" line.
Add these user commands (I let you choose the text for the tips as I all mine are in french :wink:):

AutoMoveToDir
Type: Standard

@nofilenamequoting 
@runonce @set Folder={file|noext}
@runonce CreateFolder READAUTO=no "{file|noext}"
Copy MOVE TO ".\{$Folder}" 
@keydown:shift
Rename {$Folder}

(this command will let you move all selected files to a new folder called from the name of the first file. Note that holding shift key will let you rename the folder at the end of the command if you need)

ContentsToCurrentFolder
Type: Standard

@dirsonly
@nofilenamequoting
Copy MOVE FILE "{filepath$}\*" HERE
Delete QUIET NORECYCLE

(this command will let you move the contents of the selected folders to the current one and delete the empty folders at the end of the command)

MoveToParentFolder
Type: MS-DOS Batch

@set ChildPath={sourcepath$|noterm}
@runmode hide
Copy MOVE * TO ..
Go ..
@keydown:shift
@keydown:none
rmdir {$ChildPath}

(this command will let you move all contents from a folder to the parent one and delete the empty folder. Note that when holding shift key, the folder will not be removed)

Now the user commands are set, you can go to "Context Menu" tab to set up the commands for all listers context menus.
Show the "Lister Context" menu. Right click on the menu, and select Insert New -> New Button
Edit the button with this code:

MoveToParentFolder

You can also add this button to both "Lister ZIP Context" & "Lister FTP context" context menus.

Next step is to set the buttons for files/folders context menus:
Go to Settings -> FileTypes

Edit the "All Folder" line. Go the "Context Menu" tab and choose New.
Put this code for the ContentsToCurrentFolder:

@runonce ContentsToCurrentFolder

Same as last step, edit now the "All Files & Folders" line.
Create this new command to use AutoMoveToDir:

@runonce AutoMoveToDir

You can also create a new command to move the selected files/folders to the parent directory:

Copy MOVE TO ..

That's all you normally have to do. If you want, you can also set up a Three button to call the 3 commands described in this thread (use only the user commands names as the function to set up the buttons).

These commands are really handy to move files all around when working with downloads, archives, etc.... Let's give it a try if you will, and if anyone has any improvement ideas, don't hesitate to share them!

Hope this thread is helpful... (note that some of the user commands are not from me... a lot was already discussed on the forum, it's the way I ended up implementing them)

Neat. I can use all three (i have some variation of the first one, though). The "delete empty folder" in the third is also nice, with shift modifier.

Very useful. I have some comments on the first button: Instead of only taking the first or the last file, it would be good if the name giving file could be
selected per focus. Even if all items are selected, the focus still can be moved around & provide the name of the folder. I don´t know if this
is possible, since i didn´t find no "fromfocus" command.

@set ChildPath={sourcepath$|noterm}
@runmode hide
Copy MOVE * TO ..
Go ..
@keydown:shift
@keydown:none
rmdir {$ChildPath}

A WORD OF WARNING! If you use the above command or

Copy MOVE * TO ..
Delete FILE . QUIET
Go ..

NOTE THE FOLLOWING.....

if you have a folder named the same its parent, say ...\abc\abc\file1.exe

and you are currently inside the first abc folder, select (the second) abc folder, and execute the above commands, the subfolder is merged with parent and everything is DELETED including all contents! I found out the hard way.

We need a way to feed (fully resolve?) the initial ABSOLUTE path of the folder from which to move its contents out, and then delete ONLY that.

if you have a folder named the same as its parent folder, say ...\abc\abc\file1.exe

lets say i am in the second abc folder, any way to move the file1.exe up one level and delete its parent, WITHOUT deleting everything, as i described in my post above!?

Yes, see my first reply in the Quick buttons for directory organisation thread.

[Update 14/Dec/2015: The linked post seems to have been lost, possibly while tidying up the other thread, although not intentionally. Quick buttons for directory organisation is a working link for the thread, but the post of mine which I referred to above is no longer there and what is now my first reply is not that relevant.]

Thanks Leo, that solved it. I somehow missed that post when I was searching this forum

I've moved discussion of creating Move To and Copy To context menu items to a separate Help & Support thread: Move To and Copy To context menus.