Created
September 3, 2024 10:18
-
-
Save fhyfirman/f83235afd495955540c39be985b10e41 to your computer and use it in GitHub Desktop.
Ruby Script for List All Matching Pattern Files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'find' | |
# Define the directory to search | |
directory_to_search = 'app/views' | |
# Define the pattern to match files | |
file_pattern = /.*_th\.html\.erb$/ | |
# Define the output file | |
output_file = 'email_templates_th.txt' | |
# Initialize an array to hold the matching file paths | |
matching_files = [] | |
# Search for files matching the pattern | |
Find.find(directory_to_search) do |path| | |
if path =~ file_pattern | |
matching_files << path | |
end | |
end | |
# Write the matching file paths to the output file | |
File.open(output_file, 'w') do |file| | |
matching_files.each { |file_path| file.puts(file_path) } | |
end | |
puts "Matching files have been listed in #{output_file}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment