Length of a sample might be:
renoise.song().instruments[1].samples[1].sample_buffer.number_of_frames
Cutting the sample data to a length I suppose you would have to create a new sample buffer, copy the sample buffer data you want into the new sample (within a loop) and then delete the old sample? Could be slow though on large samples with a large trim area and also doing it in a batch loop. Note that that was specified by re.dread with his dSampleTrim tool:
WARNING: Batch trimming samples can take quite a bit of time!
(Also quickly see trimming from sample_buffer )