Copy data base structure

Hi there,

We are using DT Pro Office for almost year now and it is time to start new data base. What we want to do is put each fiscal year into one data base. We need to scan last 7 years of data to get rid of papers filed in boxes (storage).
Accounting lady wants one file per year so each fiscal year has it’s own separate file. We want to burn those on CDs and keep them on external HD as well.

Maybe there is answer to the following question but I couldn’t find it with search, how can I copy structure of the DB to have same folders arrangement for each of the years I will do? We spent considerable time building perfect folders structure with vendors and services and customers that we want to keep it for new data bases as well.

You could use this script:


tell application id "com.devon-technologies.thinkpro2"
	try
		set theNum to my duplicateGroups(the selection, incoming group of current database, " copy")
		if theNum is 0 then error "Please select one or more groups."
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
	end try
end tell

on duplicateGroups(theRecords, theDestination, theSuffix)
	local theRecord, theName, theCopy, theNum
	set theNum to 0
	tell application id "com.devon-technologies.thinkpro2"
		repeat with theRecord in theRecords
			if type of theRecord is group then
				set theName to name of theRecord
				if theSuffix is not "" then set theName to theName & theSuffix
				set theCopy to create record with {name:theName, type:group} in theDestination
				set theNum to theNum + (my duplicateGroups(children of theRecord, theCopy, "")) + 1
			end if
		end repeat
	end tell
	return theNum
end duplicateGroups

Just select one or more groups, the copied hierarchy will be stored in the inbox. Afterwards move it to the desired destination, e.g. a new/other database.

This will never work for mer. i don’t know how to use scripts. I thought that there is some function in software that would allow such copy of empty data base.

Scripts might look intimidating at first sight, but in fact what Christian supplied IS a “function in software” that will allow you to copy the structure of an existing database, without content.

DT Pro and DT Pro Office are among the most scriptable of Mac applications. That means that many operations that a user might want to add, especially operations that add automation, can be added to the application, which is highly extensible in this way…

You could make a copy of your existing database in the Finder (be sure to close the database first!), then open the copy and go through each group, manually deleting all the content. You would end up with what you desire, an empty database into which you can now add new content.

But that’s sheer drudgery, especially for a large database. The script supplied by Christian will automate the procedure.

Note that DT Pro and DT Pro Office already come with many scripts that you will probably use for various purposes, and they are supplied as “software functions”. In the menubar, click on the Scripts menu (a stylized scroll character) and look at the examples. Would you like to change the Creation Date of a document? The “Set Date” script within the “Dates” folder will let you do that.

You can easily add the script supplied by Christian to the available software functions in DT Pro/Office. Here’s how:

  1. Select and copy to the clipboard the content of the “box” in Christian’s post.

  2. Launch Apple’s AppleScript editor application and paste the contents of the clipboard into it. Compile the script and Save it, e.g., to the Desktop, with a name such as “Create Empty Structure”.

  3. Back in DT Pro/Office, click on the Scripts menu in the menubar and choose the option to open the scripts folder. This will open that folder in the Finder.

  4. Back in the Finder, drag the script you saved into the Scripts folder, placing it either at the top level, in an existing subfolder (if one is appropriate), or in a new subfolder if you wish.

  5. Back in DT Pro/Office, click on the Scripts menu and choose the option to update the menu. Now this procedure will be available any time you wish to copy the structure of an existing database, but without content. You have a new “software function” that’s immediately at hand whenever you wish to use it!

Now that you have seen how a useful new procedure can be added to the application, you might want to keep an eye on discussions in the Scripting section of the user forum. There are many users who write scripts and post them there, and Christian often supplies suggestions and scripts that do what a user needs. You may never tackle the job of writing your own scripts, but you may find and use procedures developed by the user community that make your own work more productive.

NOTE: Whenever the DEVONthink application is updated,the Install Add-ons routine will rewrite the content of DEVONthink’s Scripts menu, which means that you should keep your collection of “extra” scripts copied elsewhere, so that they won’t be lost and can easily be added back.

Thank you for all the effort. I will sure try to make this work because it would be really useful to our problem.

I have this script in my Script folder and having followed the instructions as best I can -whats next? I have opened a new data base and tried to run the script. I get an error notice that no folder is selected – After selecting several different folders in the new basic DB nothing happens. This script was written in 2010 could this be a factor. Help please

Charlie

tell application id “com.devon-technologies.thinkpro2”
try
set theNum to my duplicateGroups(the selection, incoming group of current database, " copy")
if theNum is 0 then error “Please select one or more groups.”
on error error_message number error_number
if the error_number is not -128 then display alert “DEVONthink Pro” message error_message as warning
end try
end tell

on duplicateGroups(theRecords, theDestination, theSuffix)
local theRecord, theName, theCopy, theNum
set theNum to 0
tell application id “com.devon-technologies.thinkpro2”
repeat with theRecord in theRecords
if type of theRecord is group then
set theName to name of theRecord
if theSuffix is not “” then set theName to theName & theSuffix
set theCopy to create record with {name:theName, type:group} in theDestination
set theNum to theNum + (my duplicateGroups(children of theRecord, theCopy, “”)) + 1
end if
end repeat
end tell
return theNum
end duplicateGroups

The script is run in your old database, not the new database.

  1. Open your old database
  2. Select one or more groups
  3. While the groups are selected, run the script
  4. A new set of groups that matches the hierarchy of the groups you selected in step (2) will be found inside the Inbox of your old database
  5. Create a new database and open it
  6. Switch back to the old database
  7. Select the newly created groups in the Inbox
  8. Drag them to the new database

The script creates a duplicate hierarchy of the groups you selected in step (2). It does not create duplicates or replicants of documents.