Select, create and move

I want to extend the excellent button here by leo

@nofilenamequoting @runonce:@set dirname={dlgstringS|Enter name of folder to move selection into|{file$|noext}} Copy MOVE HERE FILE="{file$}" CREATEFOLDER="{$dirname}"

I need

  1. user selects a file
  2. show a dialogue with the file name without the extension (store this string $dirname)
  3. create a folder $dirname
  4. select all the files starting with $dirname
  5. move selected files to the new folder $dirname

Some typical filenames

2doc_000.jpg 2doc_001.jpg 2doc_002.jpg 2doc_003.jpg 2doc_000.jpg 3doc_001.jpg 3doc_002.jpg 3doc_003.jpg 5doc_000.jpg 5doc_001.jpg 5doc_002.jpg 5doc_003.jpg

Many thanks

I think this does what you want:

@nofilenamequoting @runonce:@set dirname={dlgstring|Enter name of folder to move into|{file$|noext}} Select "{$dirname}*" DESELECTNOMATCH TYPE=files Copy MOVE HERE CREATEFOLDER="{$dirname}"

If you want it to move directories which start with the pattern as well:

@nofilenamequoting @runonce:@set dirname={dlgstring|Enter name of folder to move into|{file$|noext}} Select "{$dirname}*" DESELECTNOMATCH Select "{$dirname}" DESELECT Copy MOVE HERE CREATEFOLDER="{$dirname}"

(I haven't tested the second one, but that should let you move files & directories without having to worry about errors moving the $dirname directory into itself if it already exists when you run the button.)

(Not sure if @runonce is still needed -- that may be fixed now -- but I've left it in anyway as it doesn't hurt.)

[quote="leo"]I think this does what you want:

@nofilenamequoting @runonce:@set dirname={dlgstring|Enter name of folder to move into|{file$|noext}} Select "{$dirname}*" DESELECTNOMATCH TYPE=files Copy MOVE HERE CREATEFOLDER="{$dirname}"[/quote]
This is brilliant.

Many thanks

[quote="leo"]
If you want it to move directories which start with the pattern as well:

@nofilenamequoting @runonce:@set dirname={dlgstring|Enter name of folder to move into|{file$|noext}} Select "{$dirname}*" DESELECTNOMATCH Select "{$dirname}" DESELECT Copy MOVE HERE CREATEFOLDER="{$dirname}"

(I haven't tested the second one, but that should let you move files & directories without having to worry about errors moving the $dirname directory into itself if it already exists when you run the button.)

(Not sure if @runonce is still needed -- that may be fixed now -- but I've left it in anyway as it doesn't hurt.)[/quote]
Today I don't need to move folders :wink: but who knows what code will be needed tomorrow? I'll add the code to the right mouse button action just in case.