Fix bash script to handle removed/renamed files