Button to move files in folder named from file

Here is a simple button to move selected files to a new folder based on the name of the first selected file. The folder name can be changed after the move command if shift key is held down.

The second button was already posted somewhere on this forum and move all files to the parent directory and delete the folder.

<?xml version="1.0"?>
<button backcol="none" display="both" separate="yes" textcol="none" type="three_button">
	<label>Déplacement Rapide</label>
	<icon1>#opentoolbar</icon1>
	<button display="both">
		<label>Déplacer dans un dossier auto</label>
		<tip>Déplacer dans un dossier du nom du fichier</tip>
		<icon1>#makedir</icon1>
		<function type="normal">
			<instruction>@nofilenamequoting </instruction>
			<instruction>@runonce @set Folder={file|noext}</instruction>
			<instruction>@runonce CREATEFOLDER &quot;{file|noext}&quot;</instruction>
			<instruction>Copy MOVE TO &quot;.\{$Folder}&quot;</instruction>
			<instruction>@keydown:shift </instruction>
			<instruction>Rename {$Folder}</instruction>
		</function>
	</button>
	<button backcol="none" display="both" textcol="none">
		<label>Déplacer dans le dossier parent</label>
		<tip>Déplacer les fichiers dans le dossier parent et supprimer le dossier counant</tip>
		<icon1>#opentoolbar</icon1>
		<function type="batch">
			<instruction>@set ChildPath={sourcepath$|noterm}</instruction>
			<instruction>@runmode hide</instruction>
			<instruction>Copy MOVE * TO ..</instruction>
			<instruction>Go ..</instruction>
			<instruction>rmdir {$ChildPath}</instruction>
		</function>
	</button>
</button>

Hope this can help!
(sorry, tips are in french :wink:)

just a little change, the button couldn't work in the case folders are broswed automatically after creation.

READAUTO=no is added when creating the folder.

<?xml version="1.0"?>
<button backcol="none" display="both" separate="yes" textcol="none" type="three_button">
   <label>Déplacement Rapide</label>
   <icon1>#opentoolbar</icon1>
   <button display="both">
      <label>Déplacer dans un dossier auto</label>
      <tip>Déplacer dans un dossier du nom du fichier</tip>
      <icon1>#makedir</icon1>
      <function type="normal">
         <instruction>@nofilenamequoting </instruction>
         <instruction>@runonce @set Folder={file|noext}</instruction>
         <instruction>@runonce CREATEFOLDER READAUTO=no &quot;{file|noext}&quot;</instruction>
         <instruction>Copy MOVE TO &quot;.\{$Folder}&quot;</instruction>
         <instruction>@keydown:shift </instruction>
         <instruction>Rename {$Folder}</instruction>
      </function>
   </button>
   <button backcol="none" display="both" textcol="none">
      <label>Déplacer dans le dossier parent</label>
      <tip>Déplacer les fichiers dans le dossier parent et supprimer le dossier counant</tip>
      <icon1>#opentoolbar</icon1>
      <function type="batch">
         <instruction>@set ChildPath={sourcepath$|noterm}</instruction>
         <instruction>@runmode hide</instruction>
         <instruction>Copy MOVE * TO ..</instruction>
         <instruction>Go ..</instruction>
         <instruction>rmdir {$ChildPath}</instruction>
      </function>
   </button>
</button>

You can edit the original post if you want. (Editing is enabled in the download forums.)

Is it possible to put this into a right-click context menu?
I found this page, but I'm not sure how it would work with XML:

EDIT ---- SOLUTION --- MANAGED TO FIGURE IT OUT USING THIS INFO:
gpsoft.com.au/help/opus10/in ... t_Menu.htm

Pretty easy, just follow below:
Settings > File Type > All Files and Folders > Context Menu > Run an Opus function > Paste code below into box > done!

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

I'm super happy this mod exists...
older apps like "Files2Folder" don't seem to work with Win8,
there's no other options!!

Now there is!
Thx Dopus!

1 Like

To put the commands on a context menu, paste the codes above on to a toolbar temporarily, then edit the buttons to get the commands out of them. You can then use the File Type editor and paste the same commands into new context menu items, using the Run an Opus Function type.

Hello,

I'm using this button, but I'd like to change the rename command:

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

Unfortunately, it sometimes doesn't let me rename the folder, and I haven't been able to figure out why (I'd be curious to know):


Rename-02

But anyway, instead of using the rename operation, I'd rather prefer to be able to:

  1. instantly rename inline as a last step, once all the files are moved into the new created folder (so I don't have to hit F2 each time)
    or
  2. rename it once the folder is created, with the dialog below, just before the files are moved:
    New_Folder

Ideally, I'd like to test both of these options, if possible.

Also, I tried with the command "Rename INLINE" instead of "Rename {$Folder}", but no success. I also tried by adding the sync command modifier, so "@sync:Rename INLINE", but still no success (I believe that I still don't know how to use it properly).

Some help would be so appreciated.

Thanks!

I would do it like this:

@nofilenamequoting
@set Folder={dlgstring|Folder name to move to:|{file|noext}}
Copy MOVE HERE CREATEFOLDER="{$Folder}"

That will prompt you before anything happens, then move things into the new folder.

Creating the folder and then renaming it after moving is possible but a lot more complex.

2 Likes

Hello Leo,

Many thanks for your fast answer! It works like a charm!

Additionally, is there any way to force the text field to already be selected or empty when the window pops up? E.g.,
Select_All

Empty

Best regards,

For already selected, change dlgstring to dlgstringS

For empty, change the whole command to this single-line command:

Copy MOVE HERE CREATEFOLDER="{dlgstring|Folder name to move to:}"
2 Likes

Try

Rename FROM="{$Folder}"

Great, I just tried and it fixes the issue.

Thank you everyone for your help!