--[[ (c)CHDKLover Thanks msl @title Rookie11 --]] prefix="A_" function fastshoot() press("shoot_half") repeat sleep(1) until get_shooting() == true press("shoot_full") release("shoot_full") release("shoot_half") repeat sleep(1) until get_shooting() ~= true end function getImageDirs() local dcimList = os.listdir("A/DCIM", false) local i=1 if(dcimList) then table.sort(dcimList) -- while i<=#dcimList do -- if string.upper(string.sub(dcimList[i],4))~="CANON" then -- table.remove(dcimList,i) -- else i=i+1 end -- end end return dcimList end function getImageList() local imgTable = {} local dcimList = getImageDirs() local dirCount = table.getn(dcimList) local i = 0 while ( dirCount ~= i) do i = i + 1 local imgDirList = os.listdir("A/DCIM/"..dcimList[i], false) local imgCount = table.getn(imgDirList) table.sort(imgDirList) local a = 0 while (imgCount ~= a) do a = a + 1 table.insert(imgTable,"A/DCIM/"..dcimList[i].."/"..imgDirList[a]) end end return imgTable end function filter(searchString) local imageList = getImageList() local count = table.getn(imageList) local i = 0 while i ~= count do i = i + 1 if(string.find(imageList[i],searchString,17, true) == nil) then table.remove(imageList,i) i = i - 1 count = count - 1 end end return imageList end function get_last_jpg() local list_jpg = filter("JPG") local count_jpg = table.getn(list_jpg) return list_jpg[count_jpg] end function is_file_locked(file_name) local ret = false local file_info = os.stat(file_name) if file_info then if bitand(file_info["attrib"],1) == 1 then ret = true end end return ret end function file_lock(file_name) return set_file_attributes(file_name, 0x1); end function file_rename(file_name) local new_file_name = string.gsub(file_name, "IMG_", prefix.."IMG_") print(new_file_name) os.rename(file_name, new_file_name) return new_file_name end --MAIN fastshoot() file_name = get_last_jpg(); file_name = file_rename(file_name) if is_file_locked(file_name) == false then file_lock(file_name) if is_file_locked(file_name) == true then print("OK") else print("FAIL") end end