# Find and replace in Xcode

**URL:** <https://forums.kodeco.com/t/find-and-replace-in-xcode/100484>\
**Category:** 🙃 Off Topic\
**Created:** [March 4, 2020, 8:31am UTC](https://forums.kodeco.com/t/find-and-replace-in-xcode/100484 "2020-03-04T08:31:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lganti](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/lganti/32/103565_2.png) [@lganti](https://forums.kodeco.com/u/lganti)\
**Post date:** [March 4, 2020, 8:31am UTC](https://forums.kodeco.com/t/find-and-replace-in-xcode/100484/1 "2020-03-04T08:31:04Z")

</div>

I wanna go through all the files and convert `"xxx".localized()` into `NSLocalizedString("xxx", comment: "")`

This is what I have currently as part of a `.sh` file

```
find ./[Directory] -name "*.swift" -print0 | while read -d $'\0' file

do
	# fetches all .localized() e.g. "Hello world".localized()
	instances=echo grep -R ".localized()" $file | awk -F "= " '{print $2}'
	for instance in $instances
	do
		# this does nothing . . . ? also the "instance" that needs to be fed into the `NSLocalizedString` should actually 
		# be `instance | awk -F ".localized()" '{print $1}'` so that I just get "Hello world" but awk doesn't seem to work without the grep piping . . ?
		sed -i "s/instance/NSLocalizedString(instance, comment: '')/g" "$file"
	done
done

```

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [April 3, 2020, 5:49am UTC](https://forums.kodeco.com/t/find-and-replace-in-xcode/100484/2 "2020-04-03T05:49:50Z")

</div>

@lganti Do you still have issues with this?

---

<div class="post-metadata">

**Author:** ![lganti](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/lganti/32/103565_2.png) [@lganti](https://forums.kodeco.com/u/lganti)\
**Post date:** [April 4, 2020, 1:20pm UTC](https://forums.kodeco.com/t/find-and-replace-in-xcode/100484/3 "2020-04-04T13:20:17Z")

</div>

No, took an alternative approach as I couldn’t figure it out after n hours. Can be closed. Thanks!
