How can I select only certain types of multiple files under a folder or model easily?

Hello fellow developers!
I am a novice developer but have created several games last 6 months.

Now I need to replace a function name
in 675 scripts in a folder.
I found the code for batch replace but couldn’t find the one for batch selection.

Does anyone know of the function or codes in Command Bar?
Thank you in advance!

I wrote the code as follows but it doesn’t work.
I want to replace “QA_Manager” with “QA_Manager2”.


for _, s in ipairs(game.Selection:GetDescendants()) do
if s.ClassName == “Script” then
tbl ={}
table.insert(tbl, s)

	game.Selection = tbl:Get()
end

end

local termToReplace = “QA_Manager”
local replaceWith = “QA_Manager2”

for _, s in ipairs(game.Selection:Get()) do
s.Source = s.Source:gsub(termToReplace, replaceWith)
end


I appreciate if someone tell me which part is wrong.

675 scripts???!??!! You should be using ModuleScripts if you are reusing a function multiple times. Also, you can press ctrl+shift+f and type in the function name, and replace it with the new function name.

2 Likes

I don’t know why you’re bothering placing the scripts from :GetDescendants() into a separate table when you can change their source right there.

for _,v in pairs(game.Selection:Get()) do
	for _,s in pairs (v:GetDescendants()) do
		if s.ClassName == "Script" then
			s.Source = s.Source:gsub("QA_Manager", "QA_Manager2")
		end
	end
end
1 Like

Yes, I use module scripts called QA_Manager and QA_Manager2 in Replicated Storage. The 675 scripts parented to respective small boards is small and basically call the function in module scripts.

I tried ctrl + shift + f and designated the folder name in “Where to look” but all scripts in game were selected. I just want to select script files in PresentContinousTenseArea folder.

Wow…this beautiful code works perfectly.
Thank you so much!

1 Like