Globally replace text in several files: Difference between revisions

Improved version. Adheres more closely to intention of task.
(Initial FutureBasic task solution added)
(Improved version. Adheres more closely to intention of task.)
Line 648:
url = fn URLByAppendingPathComponent( desktopURL, fileNames[i] )
url = fn URLByAppendingPathExtension( url, @"txt" )
CFStringRef fullText = fn StringWithFormat( @"%@ What an interesting city.", originalText )
fn StringWriteToURL( originalTextfullText, url, YES, NSUTF8StringEncoding, NULL )
MutableArrayAddObject( mutURL, url )
next
Line 656 ⟶ 657:
fileContentStr = fn StringWithContentsOfURL( mutURL[i], NSUTF8StringEncoding, NULL )
NSLog( @"Contents at: %@ = %@", fn URLPath( mutURL[i] ), fileContentStr )
CFStringRef modifiedText = fn StringByReplacingOccurrencesOfString( fileContentStr, originalText, replacementText )
fn StringWriteToURL( replacementTextmodifiedText, mutURL[i], YES, NSUTF8StringEncoding, NULL )
next
NSLog( @"\nReplacement text:" )
Line 672 ⟶ 674:
<pre>
Original text:
Contents at: /Users/ken/Desktop/file1.txt = Goodbye London! What an interesting city.
Contents at: /Users/ken/Desktop/file2.txt = Goodbye London! What an interesting city.
Contents at: /Users/ken/Desktop/file3.txt = Goodbye London! What an interesting city.
 
Replacement text:
Contents at: /Users/ken/Desktop/file1.txt = Hello New York! What an interesting city.
Contents at: /Users/ken/Desktop/file2.txt = Hello New York! What an interesting city.
Contents at: /Users/ken/Desktop/file3.txt = Hello New York! What an interesting city.
</pre>
 
 
 
 
=={{header|Go}}==
715

edits