I am writing a script to change a bone position on all my animations. Why doesn't my script work?
While the outline of your idea is right, altering the animation data takes a bit more. Firstly armatures contain two sets of bone data, one is the rest position that we change in edit mode when creating the rig, the second set is the pose bone data that we animate. The object.data.bones that you are using is the edit bone data. Using the pose bones found at object.pose.bones you could position and keyframe the bones but you will find that altering the keyframe data directly to be easier for your task.

An action contains a list of fcurves with each fcurve containing the animation data for one value, so there is one fcurve for the x location and another for the y location and so on, so you need to alter each value separately. Each curve has a list of keyframes that contains the frame and value used for the property that is keyframed. This leads to going through the fcurves of an action and looking at the data_path and array_index to decide if it is a value you want to alter.

If you are unsure of the data_path or array_index values, you can find them in the graph editor properties region.



To adjust the location of a bone in every action you could use the following.

import bpy

target_bone = 'ikHeelRight'

# Adjustments in (x, y, z) direction
adjustments = (1, 1, 0)

for act in bpy.data.actions:
    for fc in act.fcurves:
        if target_bone not in fc.data_path or 'location' not in fc.data_path:
            continue

        assert 0 &lt;= fc.array_index &lt; 3  # always good to make your assumptions explicit
        for p in fc.keyframe_points:
            p.co[1] += adjustments[fc.array_index]


The p.co[0] value is the frame number, so if you wanted to retime your animation you would change that.