Creating folders from filename


This is my first post so please go easy on me :smiley:.

Please could someone assist me with renaming files. What I am trying to do is move my movie collection into folders based on the filename.

For example,

Move1.avi -> Movie1\Movie1.avi

The problem I am having is I cannot understand the regular expressions or the commands correctly. I tried the standard rename using the {filename}{filename} as the target
But I end up with a folder called Movie1.avi.

How do I create a folder based on the filename without the .avi extension.



Welcome here...

Try in Rename window :
old name (.*)(\..*)
new name \1\\\0

Or button command :
Rename REGEXP PATTERN (.*)(\..*) TO \1\\\0


If you like to understand the basic of RegExp yourself, read RegExp basics: Removing characters from start/end of names article by Leo. This article is very excellent for this aim.

Best Regards

Thank You very much for the quick replies.


Sorry, the answer of above question was missed :laughing:

If you want to create a folder based on the filename without extension, create a key with following code:

CreateFolder NAME {O!|noext}


I think Albator's solution will work (I didn't test it - but he knows well)... But just so you know, you can [u]also[/u] do this quite easily with a simple hotkey or button that uses the Copy MOVE command, and not worry about regular expressions and the rename command. Here's the code for the button:

<?xml version="1.0"?>
<button display="both" icon_size="large" label_pos="right">
	<label>Move to new Folder</label>
	<tip>Move to new Folder</tip>
	<function type="normal">
		<instruction>Copy MOVE HERE CREATEFOLDER {f|noext}</instruction>

If you need to know what to do with the code above, check out the Sticky Topic: How to add buttons from this forum to your toolbars. It's quite easy to create new toolbar buttons this way...

1 Like

hi all, thanks for these last commands who help me each days, i give you a challenge once again, i think that i will use "yOyO's challenge" as label for the future questions :wink:
So, i would like a button command near to this topic, there's how i would like it works: select multiple files, press the new command, it move all the files in a subfolder and a box appears and ask you the name of this folder but it already as the name of the first files (and the name is selected, like that we win time if we want to remove it by backspace) that's all :wink:
Ready, on your marks, get set, "Gopus" !!! :slight_smile:

This seems to work:

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

Use the following code in a MS-DOS Batch Function button :wink::


@set strDir = {RS|Please enter your destination dir|{o|noext}} 
CreateFolder "{d}{$strDir}"
Copy MOVE to "{d}{$strDir}"

Please remember that you should use a MS-DOS Batch Function button (see attached picture), because DOpus cannot set the value of {o} , {f}, etc. to a local variable in many cases (I really think this is a bad bug).

Best Regards

Should NOT need to set that code to an MS-DOS BATCH file mode... Have you notified GPSoft about specific cases where you've found the control codes not working properly when used to set variaboles? Either through the support page or here on the forums?

If not, can you start a new topic for it (NOT IN THIS THREAD)?

Thanks Leo,searcher123 and sorry for the mess steje,you're right :wink:

I've tried getting this to work as a context menu item but can't get it to work. I'd appreciate help or ideas.


what's the problem :question:

Try this...

dopusrt /cmd Copy MOVE TO HERE CREATEFOLDER "{dlgstringS|name of folder to move selection into...|{file$|noext}}"

Hi, I need help about my last button

dopusrt /cmd Copy MOVE TO HERE CREATEFOLDER "{dlgstringS|name of folder to move selection into...|{file$|noext}}"

When i use it in file context menu and if i select more than 1 file, command doesn't work. I need help...

I want to copy all selected files in new folder with name proposition "the first file selected name"

I haven't tried any of the other commands in this thread but this works with both context menus and buttons:

@runonce:@set dirname={dlgstringS|Enter name of folder to move selection into|{file$|noext}}

(Same thing that I posted before, except with the FILE="{file$}" argument removed. I'm not sure if that argument was ever needed in the first place but it's definitely not needed with Opus now.)

Thanks... but very strange thing...
I try my last button in another computer and it's work :confused:

dopusrt /cmd Copy MOVE TO HERE CREATEFOLDER "{dlgstringS|Nom du dossier de destination...|{file$|noext}}"

This is a VERY handy function to have for organizing batches of files dumped into a single sub-directory. I tried just about everything previously posted in this thread and finally got a one-line script that works reliably:

@runonce dopusrt /cmd Copy MOVE TO HERE CreateFolder {file|noext}

This functions as a single-click toolbar command which creates a new sub-folder containing the selected files, named after the first file selected... no prompt for the folder name. I normally don't rename the folder right away, so this is truly a single click function. Folder renaming can always be done later, using the same number of keystrokes... or less if done as a batch.

It was tricky getting the exact sequence of terms that worked. I am using Dopus Thanks to all previous posters!... and thanks to GP Software as always. :smiley:

Minor thing:

The "TO" in there can/should be removed. You can use "TO " or "HERE" to specify the destination but "TO HERE" isn't right (although it appears to be harmless).

@set dir = {dlgstring|Name fΓΌr Ordner|}
createfolder NAME="{$dir}" READAUTO=no
Copy MOVE TO=".\{$dir}"

With DO my button doesn't work anymore. :frowning:
Message: System can't find the path