Now only the first .pic file is extracted correctly. Then the same 1st .pic file continues to be extracted, but the JPG files continue to be named according to the second .pic file, and most of them are corrupted. May be easier to set the .pic file name as an input variable?