Move File to Folder With Same Name - advice needed

Hi,

I am sure this can be (easily?) done with Dopus but I have not found out how (yet).

I want to move a file to a folder with the same name.
[ul]
[li]So let's say I have a file called "John Doe - the purpose of life.pdf". [/li]
[li]I want with one click to create a folder called "John Doe - the purpose of life" at the same location where the pdf is stored.[/li]
[li]Than move the PDF file into the (sub-folder).[/li]
[li]It would be awesome if this can be done for multiple files (moving each file into a folder location with the same name as the file, so I would not need to "move" them one by one").[/li][/ul]
Thanks in advance.

Lepo

Rename PATTERN "(.*)\.(.*)" TO "\1/\1.\2"  AUTORENAME REGEXP

should work...

Another approach - more verbose, but probably easier to understand for the regex inexperienced people:

CreateFolder NAME="{sourcepath$}\{file$|noext}" NOSEL
Copy MOVE "{file$}" TO "{sourcepath$}\{file$|noext}" 

Hi,
Thanks for the advice.
Perhaps someone can point me in the right direction because I am turning nuts and I am sure it is quite simple to do (I just can't figure out how yet.....)

I am having some difficulties as this is my first attempt to create a custom task in dopus.

I tried without success:

  1. Running the suggestions in the CLI > error messages

  2. creating a button and attaching the script to the button > nothing happens

  • Label: File2Folder
  • Function: Script Function (or Standard Function)
  • Pasted the code suggestions in the editor
  1. Using the Rename Function
  • Type : Regular Expression
  • Checked : Script Mode
  • Pasted the code suggestions in the editor between Function OnGetNewName ( ByRef GetNewNameData ) / End Function

Thanks for any help.

Cheers,
Lepo

Here's a button to play with..

<?xml version="1.0"?>
<button backcol="none" display="both" textcol="none">
	<label>Move File into Folder 2 (will be created)</label>
	<tip>Move File into Folder (will be created)</tip>
	<icon1>#default:move</icon1>
	<function type="normal">
		<instruction>CreateFolder NAME=&quot;{sourcepath$}\{file$|noext}&quot; NOSEL</instruction>
		<instruction>Copy MOVE &quot;{file$}&quot; TO &quot;{sourcepath$}\{file$|noext}&quot; </instruction>
	</function>
</button>

Hi tbone,
Thank you so much.
This is fabulous.
Absolutely fantastic.
Your help is highly appreciate and I feel I am just getting a glimpse of this Dopus Powerhouse.
Cheers,
Lepo

The Copy command can create a destination folder, so you should (in theory; untested) be able to do that in one line:

Copy MOVE {file$} HERE CREATEFOLDER={file$|noext}

(Also, you don't want to put quotes around {file$} etc., unless you also turn off automatic quoting using @nofilenamequoting, else you'll get two lots of quotes if the name has a space in it.)

1 Like

Yep, I quickly extracted these two lines and missed to copy the head of the button, sorry! o)

Will tryout the one-liner.. o)

This is a great script for me to use except I would like to create the folder in the destination pane and move the file from the source pane to the destination pane. How can the script(s) be modified to accomplish this?

Thank you in advance

For the last example leo gave, try to remove the "HERE" switch.

And you also may try this (untested):

@nofilenamequoting
CreateFolder NAME="{destpath$}\{file$|noext}" NOSEL
Copy MOVE FILE="{filepath$}" TO "{destpath$}\{file$|noext}"

Removing HERE from the one-line command should be all you need.

Sorry if this is repeated but along the same lines.

file name that is generated is Last name than First Name than "underscore," than either 4 digit code or 16 digit code and if its the 2nd file created it will have 2 after and 3 if its third, etc.

folder will be a subfolder labeled Last name followed by First Name followed by 4 or 16 digit number

example:

Jane Doe

DoeJane_1234567890123456.jpg

Folder: DoeJane1234567890123456

Can someone give me specific instructions how to automatically put corresponding files into the folders. This will be happening one at a time.

Thanks in advance!

Scott

Mode: Regular Expressions
Old name: (.+)_(.+)
New name: \1\2\\\0

Or, as a button/hotkey:

Rename REGEXP FROM=(.+)_(.+) TO=\1\2\\\0 IGNOREEXT

Hey,

I have a similar question to scottlebus. I posted it in a separate thread before finding this one.

I have files wherein the filenames consist of unique 9 digit numbers followed by text. I want to move those files to their respective folders which also consist of at least the unique 9 digit number but may have different text. Those folders are in another folder on the hard drive.

The files and folders are a combination of 123456789_Firstname_Lastname.docx. Instead of underscores, there may be spaces, or commas or no spaces at all. What will be certain though, is that the name is begins with 9 numbers.

When I tried the script above, it creates a new folder and then copies the file into it so that doesn't work for me unfortunately.

Any help would be awesome. Thanks!