GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Create folder and move selection

I wanted a button to create a new folder (after prompting for a name)
and then, move the selected content into the newly created folder.

I used this code:

@nofilenamequoting @set fn={dlgstringS|Enter Folder Name|New Folder} CreateFolder NAME={$fn} COPY MOVE TO "{s}\{$fn}"
But, it doesn't work :slight_smile:
I think there is an error in the third line

Pls help me rectify the code :stuck_out_tongue:

Looks okay to me, though the CreateFolder line should have quotes around the folder name and it's a good idea to add READAUTO=no to the command to stop it breaking when the default is yes.

There's a similar, working button to do this here:

[Quick buttons for directory organisation)

Note that the button there (like your similar one) is more complex than it needs to be if you always want to move files. The buttons let you click them without any files selected to create a new, empty folder. Or you can click the with files selected to create a new folder and move the selected files into it.

If you don't want the button to be able to create empty folders and only care about moving files into new folders then you can simplify things to one line:

Copy MOVE HERE CREATEFOLDER="{dlgStringS|Enter Folder Name|New Folder}"

(Edit: I've just added this simplified version to the thread I linked as well.)

Thanks Leo!

[quote="leo"]If you don't want the button to be able to create empty folders and only care about moving files into new folders then you can simplify things to one line:

Copy MOVE HERE CREATEFOLDER="{dlgStringS|Enter Folder Name|New Folder}"

Actually, it did not work for me..
But it worked when it was stripped to just

Copy MOVE HERE CREATEFOLDER

I made the corrections, but it din't work.. but doesn't matter now

Not sure why it didn't work but the one which does work for you is a better command anyway. (I forgot you could do that.) I've edited the other post to use the version you found as well.