Apending Multiple Files In IDEA

7 posts / 0 new
Last post
aveenm293
Offline
Joined: 10/23/2012 - 16:02
Apending Multiple Files In IDEA

Hi All
I have just imported 2000 files into IDEA. Is there an easier way to append all at one go? Is there possibility of writing a custom script? I am using IDEA 8.5.
Thank you in advance.
Regards
Aveen
 
 

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Aveen, yes it is possible.  I will try and put something together for you.

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Aveen, here is a script that will do it, it is pretty much the same script as the import.  The FOLDER shows the location of the imd files you want to append together.  I would recommend having them in a directory one level under your working folder.  This will read through all the files in that directory and append them together.

 


Option Explicit
Const FOLDER = "C:\Users\Brian\Documents\My IDEA Documents\IDEA Projects\Samples\aveen test\"
Const EXTENSION = "*.IMD"
Dim workingFolder As String
Sub Main 
	workingFolder =Client.WorkingDirectory() 
	Call importFiles()
	client.refreshFileExplorer
End Sub
Function importFiles() 
	Dim Files As String 
	Dim filename As String 
	Dim dbName As String 
	Dim db As database
	Dim task As task
	Files = Dir(FOLDER & EXTENSION) 
	Dim bFirstPassInd As Boolean  
	bFirstPassInd = true 
	Set db = Client.OpenDatabase(FOLDER & Files)
	Set task = db.AppendDatabase
	Files = Dir 
	 Do  
	 	' Get the next file name and place it in FileList.  
	 	If Len(Files) > 1 Then  
	 		
	 		task.AddDatabase FOLDER & Files
	 	End If  
	 	Files = Dir 
	 Loop While Files <> ""
	 dbName = client.uniquefilename("Append Databases")
	task.PerformTask dbName, ""
	Set task = Nothing
	Set db = Nothing
	Client.OpenDatabase(dbName)
	 Set db = Nothing
	 Set task = Nothing
End Function

mtzaman
Offline
Joined: 02/19/2014 - 10:36

Hi Brian,
Is there any reason why you suggest leaving the source files in a seperate directory?

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

There are a couple of reasons for that suggestion.  This script performs an append of all the imd files located in that particular directory.  If you left it at the top level so either at the project folder or working folder level the script would try and append every imd file, more than likely you will have files in there that are not of the same type.  By placing all the files you wish to append one level lower you can isolate all the imd files that you wish to append together.  One of the limitations of the append is that all the files have to be located in the project or working folder, as IDEA allows one level below that, that is usually the best option for this type of script.

Hope that makes sense.

city1
Offline
Joined: 10/21/2014 - 04:59

This script is very useful. Is there a way to modify the script such that there is an interface for the user to select the FOLDER? Thank you.

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi City1, sorry I originally missed your comment.  You can find the script here if you still need it: http://ideascripting.com/forum/append-multiple-files-same-folder