Rename multiple Idea Files

8 posts / 0 new
Last post
idemnos's picture
idemnos
Offline
Joined: 06/17/2016 - 13:25
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's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

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
Offline
Joined: 10/26/2018 - 08:40

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?

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

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
Offline
Joined: 10/26/2018 - 08:40

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's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

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
Offline
Joined: 10/26/2018 - 08:40

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
 
 

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

No problem, glad you got it working.