Skip to content

bidsmith mv

Every resource in a .bid file has a short name you use to refer to it — the bit in quotes after the type:

resource "google_ads_ad_group" "reklama_1_7" {
# ...
}

That name (reklama_1_7) is an internal handle. Other resources point at it, and you read it in plans and diffs. When you adopt an existing account with refresh, bidsmith has to invent these names for you, and it often lands on awkward, machine-generated ones with number suffixes — reklama_1_7, niestandardowa_wideo_2023_05_24_5, and worse.

mv renames them. It rewrites the resource and every reference to it, across all your files, in one step.

Terminal window
bidsmith mv google_ads_ad_group_ad.reklama_1_7 google_ads_ad_group_ad.preroll_ad

Synopsis

Terminal window
bidsmith mv <FROM> <TO> [--path PATH]
bidsmith mv --from-file <PATH> [--path PATH]

Arguments

ArgumentDescription
FROMThe resource’s current address: <type>.<name> (for example google_ads_ad_group.reklama_1_7). Omit when using --from-file.
TOThe new address: the same type, a new name. Omit when using --from-file.

An address is normally just <type>.<name>. If the same name is used in more than one file, bidsmith asks you to be specific and qualify it with the file it lives in: <file>.<type>.<name> (for example singapore_12sec.google_ads_ad_group.reklama_1_7). Each .bid file is its own little namespace, named after the file.

Flags

FlagDefaultDescription
--from-file PATHRename many resources at once. Reads <from> <to> pairs from a file, one per line. Use - to read from standard input. Can’t be combined with the FROM / TO arguments.
--path PATH.The file or directory to rewrite. A directory is walked recursively — important, because a reference can live in a different file than the resource.

Environment variables

None. mv runs entirely offline.

Exit codes

CodeMeaning
0The rename succeeded (or FROM and TO were already the same — nothing to do).
1The resource wasn’t found, the new name is already taken, the name was ambiguous, or the rename would have broken a reference. With --from-file, any one bad rule fails the whole batch. Nothing is written in these cases.
2The address was malformed, the new name isn’t valid, you tried to change the type, or the arguments were given the wrong way (for example both positional and --from-file).

Examples

Clean up a machine-generated name

Terminal window
bidsmith mv google_ads_ad_group_ad.reklama_1_7 google_ads_ad_group_ad.preroll_ad

Renames the ad and updates everything that referred to it. Run bidsmith plan afterward to confirm Google Ads sees no change.

Disambiguate when the same name is used in two files

Terminal window
bidsmith mv singapore_12sec.google_ads_ad_group.niestandardowa_wideo_2023_05_24_5 \
singapore_12sec.google_ads_ad_group.instream_12sec

The singapore_12sec. prefix is the file (singapore-12sec.bid). Use it when a plain <type>.<name> rename reports that the name exists in more than one file.

Rename inside one folder

Terminal window
bidsmith mv google_ads_campaign.old google_ads_campaign.new --path campaigns/

Rename many at once

A freshly adopted account can have hundreds of machine-generated names. Renaming them one at a time is a slog, so mv takes a batch file: one <from> <to> pair per line (an arrow is optional). Blank lines and anything after # are ignored.

# renames.txt — clean up the Singapore 12s campaign
google_ads_ad_group.niestandardowa_wideo_2023_05_24_5 -> google_ads_ad_group.instream_12sec
google_ads_ad_group_ad.reklama_1_7 -> google_ads_ad_group_ad.preroll_ad
google_ads_campaign_criterion.location_geotargetconstants_2702 -> google_ads_campaign_criterion.location_singapore
Terminal window
bidsmith mv --from-file renames.txt

The whole batch is all-or-nothing. If any line is wrong — a name that doesn’t exist, a target that’s already taken, two lines renaming to the same name, or a rename chain (a → b and b → c in the same run) — bidsmith reports it and writes nothing. Fix the file and run again. One clean run, one git diff to review.

What it changes — and what it doesn’t

  • ✅ The resource "<type>" "<name>" line for the resource itself.
  • ✅ Every reference to it (google_ads_ad_group.<name>.id and similar), wherever it appears — even in other files.
  • ❌ The name attribute inside the resource (the real campaign / ad group name that Google Ads shows). mv only touches the internal handle. To change the public-facing name, edit the name = "..." attribute and apply as usual.
  • ❌ Anything in your Google Ads account.

Comments, spacing, and alignment in your files are left exactly as they were — only the renamed identifiers change.

See also