ShareShortcuts
Fork “Replace Text”

Built something new on top of this Shortcut? Share it as a fork: it becomes a Shortcut of your own, which you manage, and both pages link to each other so hunter9888x gets credit.

  1. 1Get the Shortcut and change it in the Shortcuts app. Give it a name of its own.
  2. 2Share it from the Shortcuts app and copy the iCloud link.
  3. 3Come back here, paste the link and describe what is different, e.g. “Added a step that uses Apple Intelligence to personalise the text.”
Downloads
63K
Saved
2
Actions
262
Category
Utilities
Version
1.6
Language
EN

Replace text in

File name file extension inside file

Replace between text

Save to folder /Shortcuts/Replace Text

Save to specific folder

Create folder

Created by me

What's New

Version 1.6

Some Info changes

Version History
1.6 Jan 19, 2020

Some Info changes

1.5 Jan 10, 2020

Replace between what

1.4 Dec 21, 2019

Added save too options

1.3 Dec 20, 2019

Add inside file & code rewrite

1.2 Dec 20, 2019

Fixed replace text

1.1 Dec 15, 2019

Shows where it saves

1.0 Dec 15, 2019

First release

What it does

262 actions
  1. Choose from Menu
    Replace text
  2. Choose from Menu
    in file name
  3. Ask for Input
    Replace what text in file
  4. Set Variable
    Replace text
  5. Ask for Input
    Add what text in file
  6. Set Variable
    Add text
  7. Get File
  8. Repeat with Each
  9. Set Variable
    File
  10. Get Text from Input
  11. Set Variable
    Get text
  12. Get Name
  13. Set Variable
    Name
  14. Get Details of Files
  15. Set Variable
    Extension
  16. If
  17. Replace Text
  18. Text
  19. Set Name
  20. Choose from Menu
    in file extension
  21. Ask for Input
    Replace what text in file
  22. Set Variable
    Replace text
  23. Ask for Input
    Add what text in file
  24. Set Variable
    Add text
  25. Get File
  26. Repeat with Each
  27. Set Variable
    File
  28. Get Text from Input
  29. Set Variable
    Get text
  30. Get Name
  31. Set Variable
    Name
  32. Get Details of Files
  33. Set Variable
    Extension
  34. If
  35. Replace Text
  36. Text
  37. Set Name
  38. Choose from Menu
    inside file
  39. Ask for Input
    Replace what text in file
  40. Set Variable
    Replace text
  41. Ask for Input
    Add what text in file
  42. Set Variable
    Add text
  43. Get File
  44. Repeat with Each
  45. Set Variable
    File
  46. Get Text from Input
  47. Set Variable
    Get text
  48. Get Name
  49. Set Variable
    Name
  50. Get Details of Files
  51. Set Variable
    Extension
  52. If
  53. Replace Text
  54. Text
  55. Set Name
  56. Choose from Menu
    replace between what options
  57. Choose from Menu
    Replace between what
  58. Choose from Menu
    both sides of text
  59. Ask for Input
    Look For what on left & right side of text
  60. Set Variable
    Both sides of text
  61. Ask for Input
    Replace what between both sides of text
  62. Set Variable
    Replace text
  63. Ask for Input
    Replace with what
  64. Set Variable
    Add text
  65. Get File
  66. Repeat with Each
  67. Get Name
  68. Set Variable
    Name
  69. Get Text from Input
  70. Set Variable
    Get text
  71. Replace Text
  72. Text
  73. Set Name
  74. Choose from Menu
    both sides of text (no space)
  75. Ask for Input
    Look For what on left & right side of text
  76. Set Variable
    Both sides of text
  77. Ask for Input
    Replace what between both sides of text
  78. Set Variable
    Replace text
  79. Ask for Input
    Replace with what
  80. Set Variable
    Add text
  81. Get File
  82. Repeat with Each
  83. Get Name
  84. Set Variable
    Name
  85. Get Text from Input
  86. Set Variable
    Get text
  87. Replace Text
  88. Text
  89. Set Name
  90. Choose from Menu
    two different sides of text
  91. Ask for Input
    Look for what on left side of text
  92. Set Variable
    Left side of text
  93. Ask for Input
    Look for what on right side of text
  94. Set Variable
    right side of text
  95. Ask for Input
    Replace what between left & right side of text
  96. Set Variable
    Replace text
  97. Ask for Input
    Replace with what
  98. Set Variable
    Add text
  99. Get File
  100. Repeat with Each
  101. Get Name
  102. Set Variable
    Name
  103. Get Text from Input
  104. Set Variable
    Get text
  105. Replace Text
  106. Text
  107. Set Name
  108. Choose from Menu
    two different sides of text (no space)
  109. Ask for Input
    Look for what on left side of text
  110. Set Variable
    Left side of text
  111. Ask for Input
    Look for what on right side of text
  112. Set Variable
    right side of text
  113. Ask for Input
    Replace what between left & right side of text
  114. Set Variable
    Replace text
  115. Ask for Input
    Replace with what
  116. Set Variable
    Add text
  117. Get File
  118. Repeat with Each
  119. Get Name
  120. Set Variable
    Name
  121. Get Text from Input
  122. Set Variable
    Get text
  123. Replace Text
  124. Text
  125. Set Name
  126. Choose from Menu
    create folder
  127. Ask for Input
    Set Folder Name
  128. Set Variable
    Folder name
  129. Create Folder
  130. Show Result
  131. Stop This Shortcut
  132. Choose from Menu
    save options
  133. Choose from Menu
    Replace text save options
  134. Choose from Menu
    in file name
  135. Ask for Input
    Replace what text in file
  136. Set Variable
    Replace text
  137. Ask for Input
    Add what text in file
  138. Set Variable
    Add text
  139. Get File
  140. Repeat with Each
  141. Set Variable
    File
  142. Get Text from Input
  143. Set Variable
    Get text
  144. Get Name
  145. Set Variable
    Name
  146. Get Details of Files
  147. Set Variable
    Extension
  148. If
  149. Replace Text
  150. Text
  151. Set Name
  152. Choose from Menu
    in file extension
  153. Ask for Input
    Replace what text in file
  154. Set Variable
    Replace text
  155. Ask for Input
    Add what text in file
  156. Set Variable
    Add text
  157. Get File
  158. Repeat with Each
  159. Set Variable
    File
  160. Get Text from Input
  161. Set Variable
    Get text
  162. Get Name
  163. Set Variable
    Name
  164. Get Details of Files
  165. Set Variable
    Extension
  166. If
  167. Replace Text
  168. Text
  169. Set Name
  170. Choose from Menu
    inside file
  171. Ask for Input
    Replace what text in file
  172. Set Variable
    Replace text
  173. Ask for Input
    Add what text in file
  174. Set Variable
    Add text
  175. Get File
  176. Repeat with Each
  177. Set Variable
    File
  178. Get Text from Input
  179. Set Variable
    Get text
  180. Get Name
  181. Set Variable
    Name
  182. Get Details of Files
  183. Set Variable
    Extension
  184. If
  185. Replace Text
  186. Text
  187. Set Name
  188. Choose from Menu
    replace between what options
  189. Choose from Menu
    Replace between what save options
  190. Choose from Menu
    both sides of text
  191. Ask for Input
    Look For what on left & right side of text
  192. Set Variable
    Both sides of text
  193. Ask for Input
    Replace what between both sides of text
  194. Set Variable
    Replace text
  195. Ask for Input
    Replace with what
  196. Set Variable
    Add text
  197. Get File
  198. Repeat with Each
  199. Get Name
  200. Set Variable
    Name

View as code
Beta

Every action of this Shortcut written out as Cherri, a programming language for Shortcuts. Great for learning how it works.

#include 'actions/text'
#define color blue
#define glyph magicWandAlt


menu "Replace text" {
item "in file name":
	prompt("Replace what text in file")
	@ReplaceText
	prompt("Add what text in file")
	@AddText
	const File = getFileFromFolder(, "")
	for _ in File {
		@File = @RepeatItem
		getText(@File)
		@GetText
		getName(@File)
		@Name
		getFileDetail(nil, "File Extension")
		@Extension
		if @Name contains @ReplaceText {
			replaceText(@ReplaceText, @AddText, @Name)
			const Text = "{@GetText}"
			setName(Text, "{}.{@Extension}")
		}
	}
item "in file extension":
	prompt("Replace what text in file")
	@ReplaceText
	prompt("Add what text in file")
	@AddText
	const File1 = getFile("")
	for _ in File1 {
		@File = @RepeatItem
		getText(@File)
		@GetText
		getName(@File)
		@Name
		getFileDetail(nil, "File Extension")
		@Extension
		if @Extension contains @ReplaceText {
			replaceText(@ReplaceText, @AddText, @Extension)
			const Text1 = "{@GetText}"
			setName(Text1, "{@Name}.{}")
		}
	}
item "inside file":
	prompt("Replace what text in file")
	@ReplaceText
	prompt("Add what text in file")
	@AddText
	const File2 = getFile("")
	for _ in File2 {
		@File = @RepeatItem
		getText(@File)
		@GetText
		getName(@File)
		@Name
		getFileDetail(nil, "File Extension")
		@Extension
		if @GetText contains @ReplaceText {
			replaceText(@ReplaceText, @AddText, @GetText)
			const Text2 = "{}"
			setName(Text2, "{@Name}.{@Extension}")
		}
	}
item "replace between what options":
	menu "Replace between what" {
	item "both sides of text":
		prompt("Look For what on left & right side of text")
		@BothSidesOfText
		prompt("Replace what between both sides of text")
		@ReplaceText
		prompt("Replace with what")
		@AddText
		const File3 = getFile("")
		for _ in File3 {
			getName(@RepeatItem)
			@Name
			getText(@RepeatItem)
			@GetText
			replaceText("(\{@BothSidesOfText}.*) {@ReplaceText} (.*.*\{@BothSidesOfText})", "$1 {@AddText} $2", @GetText, true)
			const Text3 = "{}"
			setName(Text3, @Name)
		}
	item "both sides of text (no space)":
		prompt("Look For what on left & right side of text")
		@BothSidesOfText
		prompt("Replace what between both sides of text")
		@ReplaceText
		prompt("Replace with what")
		@AddText
		const File3 = getFile("")
		for _ in File3 {
			getName(@RepeatItem)
			@Name
			getText(@RepeatItem)
			@GetText
			replaceText("(\{@BothSidesOfText}.*){@ReplaceText}(.*.*\{@BothSidesOfText})", "$1{@AddText}$2", @GetText, true)
			const Text3 = "{}"
			setName(Text3, @Name)
		}
	item "two different sides of text":
		prompt("Look for what on left side of text")
		@LeftSideOfText
		prompt("Look for what on right side of text")
		@RightSideOfText
		prompt("Replace what between left & right side of text")
		@ReplaceText
		prompt("Replace with what")
		@AddText
		const File4 = getFile("")
		for _ in File4 {
			getName(@RepeatItem)
			@Name
			getText(@RepeatItem)
			@GetText
			replaceText("(\{@LeftSideOfText}.*) {@ReplaceText} (.*.*\{@RightSideOfText})", "$1 {@AddText} $2", @GetText, true)
			const Text4 = "{}"
			setName(Text4, @Name)
		}
	item "two different sides of text (no space)":
		prompt("Look for what on left side of text")
		@LeftSideOfText
		prompt("Look for what on right side of text")
		@RightSideOfText
		prompt("Replace what between left & right side of text")
		@ReplaceText
		prompt("Replace with what")
		@AddText
		const File4 = getFile("")
		for _ in File4 {
			getName(@RepeatItem)
			@Name
			getText(@RepeatItem)
			@GetText
			replaceText("(\{@LeftSideOfText}.*){@ReplaceText}(.*.*\{@RightSideOfText})", "$1{@AddText}$2", @GetText, true)
			const Text5 = "{}"
			setName(Text5, @Name)
		}
	}
item "create folder":
	prompt("Set Folder Name")
	@FolderName
	createFolder(@FolderName)
	show("New folder is /Shortcuts/{@FolderName}")
	stop()
item "save options":
	menu "Replace text save options" {
	item "in file name":
		prompt("Replace what text in file")
		@ReplaceText
		prompt("Add what text in file")
		@AddText
		const File = getFile("")
		for _ in File {
			@File = @RepeatItem
			getText(@File)
			@GetText
			getName(@File)
			@Name
			getFileDetail(nil, "File Extension")
			@Extension
			if @Name contains @ReplaceText {
				replaceText(@ReplaceText, @AddText, @Name)
				const Text = "{@GetText}"
				setName(Text, "{}.{@Extension}")
			}
		}
	item "in file extension":
		prompt("Replace what text in file")
		@ReplaceText
		prompt("Add what text in file")
		@AddText
		const File1 = getFile("")
		for _ in File1 {
			@File = @RepeatItem
			getText(@File)
			@GetText
			getName(@File)
			@Name
			getFileDetail(nil, "File Extension")
			@Extension
			if @Extension contains @ReplaceText {
				replaceText(@ReplaceText, @AddText, @Extension)
				const Text1 = "{@GetText}"
				setName(Text1, "{@Name}.{}")
			}
		}
	item "inside file":
		prompt("Replace what text in file")
		@ReplaceText
		prompt("Add what text in file")
		@AddText
		const File2 = getFile("")
		for _ in File2 {
			@File = @RepeatItem
			getText(@File)
			@GetText
			getName(@File)
			@Name
			getFileDetail(nil, "File Extension")
			@Extension
			if @GetText contains @ReplaceText {
				replaceText(@ReplaceText, @AddText, @GetText)
				const Text2 = "{}"
				setName(Text2, "{@Name}.{@Extension}")
			}
		}
	item "replace between what options":
		menu "Replace between what save options" {
		item "both sides of text":
			prompt("Look For what on left & right side of text")
			@BothSidesOfText
			prompt("Replace what between both sides of text")
			@ReplaceText
			prompt("Replace with what")
			@AddText
			const File3 = getFile("")
			for _ in File3 {
				getName(@RepeatItem)
				@Name
				getText(@RepeatItem)
				@GetText
				replaceText("(\{@BothSidesOfText}.*) {@ReplaceText} (.*.*\{@BothSidesOfText})", "$1 {@AddText} $2", @GetText, true)
				const Text3 = "{}"
				setName(Text3, @Name)
			}
		item "both sides of text (no space)":
			prompt("Look For what on left & right side of text")
			@BothSidesOfText
			prompt("Replace what between both sides of text")
			@ReplaceText
			prompt("Replace with what")
			@AddText
			const File3 = getFile("")
			for _ in File3 {
				getName(@RepeatItem)
				@Name
				getText(@RepeatItem)
				@GetText
				replaceText("(\{@BothSidesOfText}.*){@ReplaceText}(.*.*\{@BothSidesOfText})", "$1{@AddText}$2", @GetText, true)
				const Text3 = "{}"
				setName(Text3, @Name)
			}
		item "two different sides of text":
			prompt("Look for what on left side of text")
			@LeftSideOfText
			prompt("Look for what on right side of text")
			@RightSideOfText
			prompt("Replace what between left & right side of text")
			@ReplaceText
			prompt("Replace with what")
			@AddText
			const File4 = getFile("")
			for _ in File4 {
				getName(@RepeatItem)
				@Name
				getText(@RepeatItem)
				@GetText
				replaceText("(\{@LeftSideOfText}.*) {@ReplaceText} (.*.*\{@RightSideOfText})", "$1 {@AddText} $2", @GetText, true)
				const Text4 = "{}"
				setName(Text4, @Name)
			}
		item "two different sides of text (no space)":
			prompt("Look for what on left side of text")
			@LeftSideOfText
			prompt("Look for what on right side of text")
			@RightSideOfText
			prompt("Replace what between left & right side of text")
			@ReplaceText
			prompt("Replace with what")
			@AddText
			const File4 = getFile("")
			for _ in File4 {
				getName(@RepeatItem)
				@Name
				getText(@RepeatItem)
				@GetText
				replaceText("(\{@LeftSideOfText}.*){@ReplaceText}(.*.*\{@RightSideOfText})", "$1{@AddText}$2", @GetText, true)
				const Text5 = "{}"
				setName(Text5, @Name)
			}
		}
	}
	const SavedFile = saveFilePrompt(MenuResult)
	stop()
}
createFolder("Replace text")
saveFile("Replace text", MenuResult1, true)
show("In folder /Shortcuts/Replace text")
Decompiled with cherri 2.3.0 (GPL-2.0). May need small fixes before it compiles.

Ratings & Reviews

Write a Review
–
out of 5
★★★★★
★★★★
★★★
★★
★
0 ratings

No reviews yet. Be the first to share what you think!

Advertisement

More by hunter9888x

See All

You Might Also Like

See All
Advertisement