cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
UserID16644
Level V

Renaming multiple data table from last word of current table name

Hi, I am trying to rename multiple data table because my data table name are in directory forms. I would want to rename them according to their folder names (will be getting from the last character of the directory) 

 

Sample data table name: 

C:\Users\Desktop\Table1

C:\Users\Desktop\Table2

C:\Users\Desktop\Table3

 

I tried using Word function to get the last word from the file name, but doesn't work. Please help

 

For (w = 1, w <= N Table(), w++,
		dtName = Word(-1, Data Table(w), "\"),
		Data Table(w) << Set Name(dtName);
);

The resulting data table names should be: Table1, Table2, Table3

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Renaming multiple data table from last word of current table name

You need to retrieve the data table name

For (w = 1, w <= N Table(), w++,
		dtName = Word(-1, Data Table(w) << get name, "-"),
		Data Table(w) << Set Name(dtName);
);
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: Renaming multiple data table from last word of current table name

You need to retrieve the data table name

For (w = 1, w <= N Table(), w++,
		dtName = Word(-1, Data Table(w) << get name, "-"),
		Data Table(w) << Set Name(dtName);
);
Jim
UserID16644
Level V

Re: Renaming multiple data table from last word of current table name

Why does it prompt an error like this?

 

too many arguments{40} in access or evaluation of 'For' , For/*###*/(w = 1, w <= N Table(), w++, dtName = Word(
-1,
Data Table( w ) << get name,
"-"
), Data Table( w ) << Set Name( dtName ))

 

--- EDIT ---

I replaced the comma after the Word function with ; and is working now

For (w = 1, w <= N Table(), w++,
		dtName = Word(-1, Data Table(w) << get name, "-");
		Data Table(w) << Set Name(dtName);
);