Skip to main content

Rename multiple Idea Files

Hi there.
 
I remember Brian posted sometime ago a script that listed all files in a project. I've got a script that import data from 2 sql queries and after that some filters and joins are executed in Idea. I use as input: user, password, office number, initial date and final date. I would like to rename al the idea files created by the script, about 6, and include in the name of all files the office and dates, with the first ones is completly possible, but with the joins is not possible. Can you tell me if its possible if is it there a way to make a multiple renaming script or function, please. Thanks in advance.

Brian Element Fri, 02/16/2018 - 19:26

Hi idemnos,

If the files are being created by script you would have the option to name the new files.  Usually you will get a line like this in each task.

dbName = "New File.IMD"

If you create two variables to hold the office and the dates you can add this to the dbName such as:

dbName = "New File " & office & "-" & date & ".IMD"

Would that work for you in this scenario.  Better then going back and renaming all the files after the fact.

Gerard Usher Fri, 11/16/2018 - 09:23

Hi Brian,
I'm trying to use the current date in my dbName by using
Sub Main Call AppendDatabase() 'ReconNet_Daily_VPS_01.IMD Client.CloseDatabase "Append Databases.IMD" Client.CloseDatabase "ReconNet_Daily_TGS_01.IMD"End Sub
' File: Append DatabasesFunction AppendDatabase Set db = Client.OpenDatabase("ReconNet_Daily_TGS_01.IMD") Set task = db.AppendDatabase task.AddDatabase "ReconNet_Daily_VPS_01.IMD" dbName = "ReconNet_Joined_Databases " & "-" & Date & ".IMD" task.PerformTask dbName, "" Set task = Nothing Set db = Nothing Client.OpenDatabase (dbName)End Function
but I get the error:
Error on line 14 - File name ReconNet_Joined_Databases -11/16/2018.IMD contains invalid charachters. The following charachters \/:*?"<>[]| are not allowed.
You did mention creating a variable to hold the dates.  How do I do that?

Brian Element Fri, 11/16/2018 - 09:34

In reply to by Gerard Usher

Hi Gerard,

The error is that filename can't contain certain types of characters and the "/" is one of them so that needs to be removed.  If you want to add the current date to your file name you can add this code:

sDate = Now()
sDate = iRemove(Left(sDate, 10), "/")

and then use the sDate as part of the filename.  The now returns the current date and time.  The next line only gets the date (first 10 characters) and removes the slashes from the date.

Hopefully this helps.

Brian

Gerard Usher Fri, 11/16/2018 - 11:59

Hi Brian,
 
Thank you for the quick reply.  I added the arguments to my script and now I'm not getting any error messages but it's also display no date in the file name. I've attached my updated script to this reply.  I am probably making a rookie error in the script but, unfortunately, I can't find it :-(

Brian Element Fri, 11/16/2018 - 13:59

In reply to by Gerard Usher

Hi Gerard,

You need to add those two lines before the dbName for it to work, such as:

sDate = Now()
sDate = iRemove(Left(sDate, 10), "/")
dbName = "ReconNet_Joined_Databases " & "-" & sDate & ".IMD"

That should fix the problem, right now the sDate is blank and there is no code to actually get the current date, the two additional lines add that functionality.

Brian

Gerard Usher Fri, 11/16/2018 - 13:10

Hi Brian,
I found my mistake! I had the 2 arguments outside of the function.  I moved them to lines 11 & 12 and it works!  Thanks again for your quick help.   Sorry to have bothered you the 2nd time.
Gerard