How to move all files of folder from another folder to same S3 bucket

I’m making a script that needs to move all files from a third folder to the main one and in that list there are also those that are already in the right folder and I need to ignore them.

my_bucket/files/id/file.txt TO my_bucket/files/file.txt

my code is like this and it is only listing the objects, it is not moving

I try this code:

defmodule Script.Elixir do
 
  
  def list_objects_in_bucket do
    "my_bucket"
    |> ExAws.S3.list_objects(max_keys: 1000)
    |> ExAws.request()
    |> extract_only_route()
  end

  def copy_object(origin_path) do
    ExAws.S3.put_object_copy(
      "my_bucket/",
      "/my_folder_destiny/",
      "my_bucket",
      origin_path
    )
    |> ExAws.request()
  end

  defp extract_only_route({:ok, %{body: %{contents: contents}}}) do
    Enum.map(contents, fn %{key: route} -> route end)
  end

end