hiteksoftware.com Forum Index hiteksoftware.com
User discussion forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

saving a filename substring as a user defined variable

 
Post new topic   Reply to topic    hiteksoftware.com Forum Index -> Frequently Asked Questions
View previous topic :: View next topic  
Author Message
rblandut



Joined: 01 Jun 2009
Posts: 3

PostPosted: Mon Jun 01, 2009 2:20 pm    Post subject: saving a filename substring as a user defined variable Reply with quote

Hi, I need to use regex to extract a filename substring and save it as a user defined variable for use by another task, in doing a subsequent file rename.

e.g.
1. some_name_06012009.xls
2. save "_06012009" into a persistent variable
3. rename the original file to a generic name for processing thru a conversion script
4. rename the resulting file to add the "_06012009" back to the name.

The number changes daily, but I cannot guarantee that it is the current date.

Any helpful hints? Thanks!
Back to top
View user's profile Send private message
Robert
Site Admin


Joined: 25 May 2006
Posts: 1140

PostPosted: Tue Jun 02, 2009 9:52 am    Post subject: Reply with quote

The variable manipulate task should work here to extract the number part..

The regex needed will depend on the filenames.

does some_name_06012009.xls include special characters or only alphabets and numerals?

does it include multiple _ before 0612... or only 1 _ ?

give examples of actual filenames.
Back to top
View user's profile Send private message
rblandut



Joined: 01 Jun 2009
Posts: 3

PostPosted: Tue Jun 02, 2009 2:05 pm    Post subject: clarification Reply with quote

It includes multiple underscores. The string I want to save is not fixed, but I know how to get the piece I'm looking for using regex in a file copy task:

e.g. actual file name = THE_FILE_NAME_06022009.XLS
copy task:
filename => REGEXF=(?i)THE_FILE_NAME_[0-9]{8}.XLS
new name => THE_FILE_NAME.XLS

I need to save the string "_06022009" in a user defined variable (it's already been created and is viewable), for later use in another task. I don't see an easy way to do that.

Is there a way to write into an Automize variable from a script?

Thanks, Bob
Back to top
View user's profile Send private message
Robert
Site Admin


Joined: 25 May 2006
Posts: 1140

PostPosted: Tue Jun 02, 2009 2:40 pm    Post subject: Reply with quote

>> Is there a way to write into an Automize variable from a script? <<

from an external script/batch file or using the Script task?

Either way, you can get/set a variable.

For external script: see the Utilities menu / Commandline utilities / Set User variable

For script task: see the examples. there is one example on setting/getting variable values.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    hiteksoftware.com Forum Index -> Frequently Asked Questions All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group