Here's an attempt at solving your problem by making a few modifications to the code in this other answer.
# Import system modules
import arcpy
import os
import pathlib
def export_layers_to_single_gdb(input_gdb_folder,
target_dataset_name,
target_layer_name,
output_gdb,
overwrite_output_gdb,):
'''
Function that reads an input folder with multiple GDB files and copies one
specific layer from each GDB to the output GDB.
Parameters
----------
input_gdb_folder : str
The input folder that contains all the GDBs that will be looked into
target_dataset_name : str
The name of the dataset to serch for the target layer. If the target
layer is not contained in a dataset, just use either an empty string or
None for this value: '' or None
target_layer_name : str
The name of the layer to be copied from all input GDBs to the
consolidated output GDB
output_gdb : str
Path for the consolidated output GeoDataBase (.gdb) file.
overwrite_output_gdb : boolean
Flag that indicates whether or not the consolidated output GDB file
should be overwritten in this process in case a file with the same name
already exists on disk.
Returns
-------
None.
Outputs
-------
This function copies the target layer from several input into creates a master GDB file
'''
# Fishing out the output folder and the GDB filename
output_gdb_path = pathlib.Path(output_gdb)
output_folder = str(output_gdb_path.parent)
master_gdb = output_gdb_path.stem + output_gdb_path.suffix
# Creating master consolidated output GDB. This will store the finalized
# combined layers.
master_gdb_fullpath = os.path.join(output_folder, master_gdb)
if ((os.path.exists(master_gdb_fullpath)) and (overwrite_output_gdb)):
arcpy.Delete_management(master_gdb_fullpath)
arcpy.CreateFileGDB_management(output_folder, master_gdb)
# Get list of all GDBs in the input folder
list_of_input_gdbs = [f for f in os.listdir(input_gdb_folder)
if (f[-4:].lower()=='.gdb')]
# Looping over every input GDB file
for i,input_gdb in enumerate(list_of_input_gdbs):
# Getting the full path of the input GDB
input_gdb_fullpath = os.path.join(input_gdb_folder, input_gdb)
arcpy.env.workspace = input_gdb_fullpath
# Copying the Featureclass from the input GDB to the Master GDB
print(f"COPYING: {target_layer_name} FROM: {input_gdb}")
if (target_dataset_name is None) or (target_dataset_name == ''):
fcCopy = os.path.join(input_gdb_fullpath,
target_layer_name)
else:
fcCopy = os.path.join(input_gdb_fullpath,
target_dataset_name,
target_layer_name)
new_layer_name = target_layer_name + '_' + input_gdb
arcpy.FeatureClassToFeatureClass_conversion(
fcCopy, master_gdb_fullpath, new_layer_name)
Btw, I wasn't able to test it myself, so please let me know if it crashed on some step.