Making folder for a file based on file name

Hi guys! :slight_smile:
I have a question about a function I want. I don't know if it is solveable by using the Dopus script or not, or if this function are possible by using the existing functions in Dopus.

I need a function that works like this;

  1. I select a file.
  2. I right click at that file and choose "make a folder with same filename and put file in that folder"
    Just like winrar do "extract to separate folders", only opposite so to speak :slight_smile:
    Preferrably it would work on multiple files.

How should i proceed?
I have never tried Dopus scripting so i have no idea whether this can be fixed using that.

This button should do the trick for you.
New Folder = FileName.dcf (552 Bytes)

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

this other button does the opposite
names the file the folder name
FileName = FolderName.dcf (605 Bytes)

@nodeselect                                                                   - Delete underscores, points and %20                                          - Upper case for words, after hyphens and parenthesis               - Lower case for extensions
Rename PRESET="File = Foldername"

Try this:

Rename REGEXP IGNOREEXT PATTERN="(.*)" TO="\1\\\1"

Move into New Folder with same name.dcf (415 Bytes)

To add the command to your right click menu, see image below:

Thank you very much guys! :slight_smile:
I placed it on the toolbar and got it to work, even for multiple files!!
But how do i attach it to the context menu?
I'm an idiot, plz explain :slight_smile:

That's what the image above is showing :slight_smile:

Settings / Filetypes / All files / Context Menu Tab / New / Add Action Name (i.e. Move to new folder with same name) then add the code into the box at the bottom of the dialog.

@Leo I think it would be useful if we could drag a .dcf file into the context menu. We can already drag an existing item from one context menu to another so why not a .dcf file as well?

1 Like

Oh yeah. It went better when i ignored the *.dcf file and just pasted the code. :slight_smile:
Thank you :slight_smile:
But how do i do it if i have a dcf-file and no code, and want the function of the .vcf file in a context menu?

...and is there a downloadable opus scripting manual anywhere?
Searched a little, couldn't find any.
A manual with examples and stuff, that starts with the easy things and work its way up?

If you only had a .dcf file, you could put it on a toolbar temporarily and then edit it to see which commands it runs, then paste them into a context menu item.

.dcf files are also text/XML, so you can often just open them in a text editor or the viewer pane to see what they do. But be careful of things like quotes which get encoded to " in the XML, and things like that, which you don't need to worry about if you do it the other way.

Context menus and toolbars are quite different behind the scenes (not least because context menu items might be stored in the registry and need to work outside of Opus, depending on the type of item). That's why .dcf files can't be dragged directly into context menus like they can with toolbars. (Of course, nothing is impossible, so the ability to add that might be added one day, but it has some complexities.)

Push F1 in the program, or use the Manual links at the very top-right of the forum, or on the main GPSoft site.

1 Like

Ok, it worked flawlessly :slight_smile:
And if i want to do the opposite?

  1. Select a folder
  2. Move the file(s) in that folder one step up in the catalog structure and remove the folder
    ?
    If you can make it in script form i would appreciate it :slight_smile:
    It seems code is easier to incorporate into context menus :slight_smile:
@dirsonly 
Rename FROM={filepath$}* TO={filepath$|..}*
Delete {filepath$} NORECYCLE SKIPNOTEMPTY QUIET
2 Likes

Thanks!:slight_smile:
It all works now, thank you very much :slight_smile:
And to the rest of you, thanks for the help :slight_smile:

2 Likes

But how does this button work? (the second..)

I would like to rename the file based on the folder name..

Thanks

Hi Birba
First you need to have the button on your toolbar.
Download button to your pc.
Right click on a toolbar, click customize.
Then drag the button (dcf file you downloaded) to your toolbar.
click ok...

Once button is on your toolbar.
Make sure the file you wish to rename is inside a folder.
Click on the file, then click on the button (on toolbar).
File will automatically rename itself same name as the folder name.

Hope that makes sense
Regards,
Clicks

I tried but it doesn't work ...
But the "Rename PRESET" command in the button, shouldn't it recall a preset?

There is something strange, probably accidental, about the second button.

I edited the post to put the commands into the post so it's easier to see what we're talking about, and noticed the second button has a lot of extra text on the first line which doesn't look like it should be there. (It's off to the right so you may need to scroll to see it.)

You'd need a rename preset called File = Foldername for it to work as well.

Sorry guys forgot to include the preset...my bad
File = Foldername.orp (194 Bytes)

In the advanced rename window please import this preset file.

2 Likes

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

I am doing something wrong; it works, but only on one file. If i select multiple files, it prompts me for the first folder name and then it puts all the files in that folder.

You’ve quoted two different commands from the thread, which each do slightly different things.

Which one are you using?
What do you want to do?

Well, kind of.
It works perfectly for one file.
But if you have multiple files that you want to put in separate folders with their separate names on it, it fails; it will put every file in ONE folder.