The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Change multiple book names

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Clairekun Posted - 01/31/2013 : 05:05:22 AM
Origin Ver. and Service Release (Select Help-->About Origin): Origin 9
Operating System: Windows 7

Hello,

First of all I know very little about programming, so please explain things to me as if I were a child. I have been trying to find a way to rename imported files. I usually work with over 50 files at once, so doing it manually can get very frustrating.

The file name itself contains more information that what I would want the books to show, for example:

uselessinfo_23_moreuselessinfo.asc

I would like the book name to be "23cm", as in "measurement data + units".

I have found ways to hide file extension, so it is not necessary for you to tell me how.
4   L A T E S T    R E P L I E S    (Newest First)
Clairekun Posted - 02/26/2013 : 05:29:40 AM
In the end, I applied replace method, which I had tried before with no luck. My mistake was in typing the whole word lowercase, but it worked as soon as I typed str.Replace .

Many thanks!
greg Posted - 02/07/2013 : 3:08:41 PM
string str;
str$ = 23;
str.INSERT(1,"L="); // There's an INSERT method
str$ = %(str$)cm; // Use substitution to append
str$ =;

turns "23" into "L=23cm".

as does this code:

string str1,str2;
str1$ = 23;
str1.INSERT(1,"L="); // There's an INSERT method
str2$ = cm;
str1$ = str1$+str2$; // concatenate strings by addition
str1$ =;
Clairekun Posted - 02/06/2013 : 07:39:50 AM
Thanks for your help. I combined what you told me with other functions I found and could finally get almost what I wanted. The final result is:

A23cm

However, since Workbook names need to have a prefix, I would like the name to something like:

L=23cm or L-23cm (since, in this case, I would be using length units)

So that I can find the number more easily with only a glance. I have tried the replace and insert functions, but don't seem to get them to work.

However, if this is not possible, making the prefix lowercase would suffice.

Thanks again, you were of great help.
greg Posted - 01/31/2013 : 3:09:58 PM
If you are using ASCII Import, then the (Re)Naming section lets you specify which characters to grab out of a filename to use as Workbook or Worksheet name.
For
uselessinfo_23_moreuselessinfo.asc
you could use
Trim Filename From = 13
Trim Filename To = 14
for the Sheet name to get a sheet named '23', but since you want 'cm' appended and since I suspect the leading text "uselessinfo_" may actually vary in length, then some other solution is needed.

Setup your ASCII Import to NOT rename anything and use this script :
// BEGIN SCRIPT
doc -ef W {
string str$ = %(%H, @W,SYSTEM.IMPORT.FILENAME$);
str$ = str.GetToken(2,'_')$;
win -r %H %(str$)CM;
}
// END SCRIPT
which will loop over all worksheets in the current folder, find the actual filename, grab the part of the name delimited by '_' and add CM and use that to rename the Workbook.

To use:
After importing, copy and paste the script into the Command Window and press Enter.
Origin will prefix an 'A' since Workbook names should not begin with a number and will prompt you if it encounters a duplicate name.

Note that if your naming convention is a bit more complicated, you may need to learn some programming to customize to your needs.

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000