Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Renaming files in a particular way. 2

Status
Not open for further replies.

Jerim65

Technical User
Aug 8, 2010
99
AU

My app deals with files from a 3rd party app.

I have a routine that renames tables (files) from the 3rd party app - there are many of them in a relational database.

For years I have had a routine starting..

Code:
For lnFile = 1 To Adir(laFiles, '*.*')

	lclength = Atc('_',laFiles[m.lnFile,1])-1
	
	... then further processing

The _ is significant in the naming of the 3rd party app tables.

By chance I have attempted to change an original name (with an _ ) with another name actually containing an underscore.

Eg OLETEST_c.DBF(_) into mynew_test_c.dbf

The above lclength code gives me the position of the first _ rather than the one that is always some chrs back from the period.

To complicate matters the _c part may be _cc or _ccc.

I really need to change the lclength test to reflect the last _ before .dbf.

Could someone help with the definition of an ATC function please?
 
Coldan,

The simplest solution would probably be to use RAT() rather than ATC(). RAT() starts searching from the right-hand end of the string, rather than from the beginning.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Also helping: JustStem() gives you the part of the filename before the file extension and JustExt gives you just the extension of a file name.

You can also use forceext() to change the extension (within the variable/stringresult, not on disc), eg you can use ADIR("*.dbf_") to find files with extension and create the new name with Nexname = ForceExt(oldname,"dbf").

And to find the last _ before the file extension you can use RAtC(JustStem(oldname),"_")

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top