Help with button to move folders

I’ve been doing a series of repetitive tasks and I finally hit upon the idea that perhaps DOpus could simplify the process for me. What I’d really like is a button that would move files to one of two places (right click, one place; left click, the other) and do some rudimentary (?) checking while doing so. Here is what I’m doing: I have a series of folders with subfolders. I’m manually checking the data in these subfolders to see if it is acceptable or if it needs further checking or processing (usually, meaning that the data is incomplete). After checking all of the subfolders in a particular subfolder, I move those that are correct to a “Complete” folder on an another drive (with the folder and subfolder structure intact). Frequently, there is already a folder with the same name in the Complete folder; that is fine. However, when there is a subfolder with the same name, then I don’t want to check the contents now or combine the contents; rather, I want a new subfolder to be created (called, for example “Subfolder (1)”). [See example below]. After the complete subfolders are moved, I move the incomplete subfolders to a separate “Incomplete” folder; however, unlike the “Complete” folder, the Incomplete folder also has the year and month appended to the end of the folder name (this helps me go back later and check my incomplete data at a future date). So, for example:

[ul]C:\Not Checked
\Matter A
\Item A --Check is good
\Item C --Check is not good
\Matter C
\Item A -- Check is good
\Item B -- Check is not good

E:\Complete
\Matter A
\Item A
\Item B
\Matter B
\Item A

E:\Incomplete (2007-06)
\Matter A
\Item C
\Matter C
\Item A[/ul]
In the previous example, the following would happen:

C:\Not Checked\Matter A\Item A will be moved to E:\Complete\Matter A\Item A (1)
C:\Not Checked\Matter C\Item A will be moved to E:\Complete\Matter C\Item A
C:\Not Checked\Matter A\Item C will be moved to E:\Incomplete\Matter A\Item C (1)
C:\Not Checked\Matter C\Item B will be moved to E:\Incomplete\Matter C\Item B

So, I’d like a DOpus button that will move to the Complete folder on a left click and the Incomplete folder on a right click. Right now, I’ve been dragging, but I tend to have problems with trees expanding (or accidentally dropping a folder in the wrong spot) and having to manually check to be sure that a subfolder with the same name does not already exist. I don’t know if this sort of processing is within the scope of what DOpus commands will do, but I figured it was worth a try…

Any help will be greatly appreciated!

---Michael[/list]

To be honest, I'm not able to follow just what you want. However if you mainly want to move the selected items to one location with a left click and to a different location with a right click, then I would create a new 3 button button (those let you do different things with a left click and right click). Then set the left click button up with a command such as:

Copy MOVE TO "E:\Complete\Matter A\Item A"

And for the second (right click) button in the 3 button button I'd use something like this:

Copy MOVE TO "E:\Incomplete\Matter A\Item C"

Then when you select some files and left click the button they will be moved to the first location while a right click will move them to the second location. And if the files already exist in the location you are moving them to you should be prompted and given choices how you want to handle the duplicates (rename, overwrite, and so on).

Thanks for the quick response. Let me see if I can explain a bit more. First, the folder that I'm clicking on (whether right or left) is a subfolder. When that subfolder is moved, it needs to be moved into a similar tree location on the other drive (thus C:\Not Checked\Matter 1\Item A would move to E:\Complete\Matter 1\Item A). I need DOpus to check to move the Item A folder into a folder on the other drive with the same name as the folder at the level above the Item A folder. The bigger issue is checking to see if an Item A folder already exists on the other drive; I know that I can check manually, but that's what I'm trying to avoid needing to do. Instead, I'd like DOpus to look at the other drive and, if an Item A subfolder already exists in the Matter 1 folder, then a new Item A (1) subfolder should be created (or Item A (2), etc.).

I know that this all sounds ridiculous, but it's a system that I've developed over the last few years that, while perhaps odd or unwieldy, has worked very well. Now I'm just looking to automate some of the tasks.

So, perhaps we can break the tasks down into parts. How 'bout this:

  1. How can I have DOpus move a selected folder to another drive and have that folder be placed into a folder with the name of the original folder's parent?

  2. How can I have DOpups check to see if a folder already exists and, if it does, create a new folder with the same name but with a number appended to the end. (This would be identical to the way DOpus handles inline renames of folders when another folder with the same name exists, only I'm moving the folder, too.)

Hope that additional explanation helps rather than just confuses things more.

Someone else might have a much easier solution but I would tackle this with a script. So far I've only looked at solving your first question, I would need more exact specifics before I'd be able to work up something for question 2.

But here is what I came up with for #1.

  1. Create a new empty text file and paste the following into it:

@rem BEGIN BATCH FILE
@echo off & setlocal enabledelayedexpansion

if "%~1%" == "" exit
echo %1

rem var A is full selected file/foldername
set A=%~1

rem var B is the lister parent folder full path
set B=%~2

rem var C is the selected file/foldername only
set C=%~3

rem var D is the destination lister path
set D=%~4

rem First strip full parent folder from selected name
set "Y=!A:%B%=!"

rem Second strip selected file/foldername from selected item
rem so only the parent name remains
set "PARENT=!Y:%C%=!"

rem this creates the destination folder...
if not exist "%D%%PARENT%" dopusrt /cmd createfolder "%D%%PARENT%"

rem now move the selected to the newly created destination folder
dopusrt /cmd copy move %1 to "%D%%PARENT%"

exit

Opus button command line follows:
"D:\Mine\cmd\Test.bat" {f} {f|....} {file} {d}

where "D:\Mine\cmd\Test.bat" needs to be changed to
the name if this file
rem END BATCH FILE

  1. Save that file with an extension of .BAT and make a note of the name and location. In my example the file is called "D:\Mine\cmd\Test.bat"

  2. Next create a button in Opus and give it the following command:

"D:\Mine\cmd\Test.bat" {f} {f|....} {file} {d}

Note you will need to change "D:\Mine\cmd\Test.bat" in the button code to the exact filename of the script file you made.

Then exit customize mode, set up your source and destination listers, and give it a try. If all goes well and if you have the following directories selected in the source:

D:\test folder\source\This is a folder
D:\test folder\source\This is another folder

And your destination is say:
D:\test folder\destination

And you press the button you made, the selected directories should be moved to:

D:\test folder\destination\source\This is a folder
D:\test folder\destination\source\This is another folder

Easy ain't it? :open_mouth: :open_mouth:

Wow. I think I'm glad that I didn't try to figure out how to do this on my own. Thanks for the batch file. I will have to give that a try and see if it works. Unfortunately, I may not be able to for a day or three. I'll let you know if I have any problems.

Thanks again.

---Michael

I tried. When I click on the button, I get the following error:

An error occurred creating folder 'I:\Test\Not Checked\Matter A':
The filename, directory name, or volume label syntax is incorrect. (123)

Thanks for helping with this.

I tried. When I click on the button, I get the following error:

An error occurred creating folder 'I:\Test\Not Checked\Matter A':
The filename, directory name, or volume label syntax is incorrect. (123)

Thanks for helping with this.

Hmmmm....Well try this:

Using a text editor like Windows Notepad open the batch file and find this line in it:

if not exist "%D%%PARENT%" dopusrt /cmd createfolder "%D%%PARENT%"

Put the word ECHO at the beginning of that line then in the next line put PAUSE & EXIT so it becomes this:

echo if not exist "%D%%PARENT%" dopusrt /cmd createfolder "%D%%PARENT%" pause & exit

Then try using your button again. This time a DOS box should pop up and stop at the line that seems to be failing. Post a screen grab of it, or copy and paste it exactly in a reply and I'll see if I can see where it's going wrong.
(Make sure your Opus button is not set to run in HIDE mode or you won't see the DOS box)

OK. Here's what the DOS window shows. The error is gone now (odd), but nothing gets moved (and new folders are not created).

"I:\Test\Not Checked\Matter A\Item 1"
if not exist "I:\Test\Checked Good\ I:\Test\Not Checked\Matter A" dopusrt /cmd
createfolder "I:\Test\Checked Good\ I:\Test\Not Checked\Matter A"
Press any key to continue . . .

The script is not processing one folder at a time as it should. My guess is that might be because of your Opus button command, try posting that here next.

"I:\Test\cmd\Test.bat" {f} {f|....} {file} {d}

That looks ok, what version of Windows are you using?

Win XP Pro SP 2

Same version I'm using. Ok back in the script look for this line:

set "Y=!A:%B%\=!" 

and right below it add this line

echo %Y% & pause & exit

(And then post the DOS box results here again)

"I:\Test\Not Checked\Matter A\Item 1"
I:\Test\Not Checked\Matter A\Item 1
Press any key to continue . . .

Boy am I glad that I didn't decide to try this on my own...

We're getting close. Now just above that

set "Y=!A:%B%\=!"

line put this:

echo %A% and %B%

and then paste the results here again. Apparently that set "Y=!A:%B%=!" line is not replacing what it should. By adding the above echo %A% and %B% line, we'll see what it's being fed.

"I:\Test\Not Checked\Matter A\Item 1"
I:\Test\Not Checked\Matter A\Item 1 and I:\Test\Not Checked
I:\Test\Not Checked\Matter A\Item 1
Press any key to continue . . .

Thanks again for the help. (I'll be leaving for home in 10 minutes or so... [why am I still at the office on a beautiful day like today...?])

That's ok, I'm in and out of here a lot today myself, in fact I have to leave again myself right now. Before I log off though I'll send you a private message here with my email address so we can continue this in private without cluttering up the board.

Just in case anyone else was following this thread, the problem MSWallack was having with my script was due to extra spaces being appended to the end of the script lines when he copied and pasted the script.

Next time I post a script I'll either zip it or use the code tags to enclose it. Hopefully that'll prevent such a thing from happening again. :blush: