--[[@title renaming]]new_suffix = "jpg"file = file_browser("A/DCIM")file_new = string.sub(file, 1, (string.len(file)-3)) .. new_suffixprint("new:", file_new)os.rename(file, file_new)
Just an idea. Maybe a script is more suited to do this kind of job. Something like: create a list of all movie files on the card -> change their extensions to jpg.
--[[ @title Rename avi files to jpg Original code: disk.lua, http://chdk.setepontos.com/index.php?topic=2902.0 Original author: fudgey 2008/10/27 Licence: GPL v3 or higher--]]disk = {}-- returns list of files that contain the provided search stringfunction disk.filterImageFiles(searchString) local imageList = disk.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 imageListend--[[ Loops through directories within DCIM dir, checks to seethat each directory contains images. returns list of directories. deletes empty directories ]]function disk.getImageDirectories() local imgTable = {} --get directories that may contain images local dcimList = os.listdir("A/DCIM", false) if(dcimList) then local dirCount = table.getn(dcimList) table.sort(dcimList) --loop through directories local i = 0 while ( dirCount ~= i) do i = i + 1 --get file list local imgDirList = os.listdir("A/DCIM/"..dcimList[i], false) if(imgDirList) then local imgCount = table.getn(imgDirList) table.sort(imgDirList) if(imgCount == nil) then os.remove("A/DCIM/"..dcimList[i]) table.remove(dcimList,i) end else os.remove("A/DCIM/"..dcimList[i]) table.remove(dcimList,itemCount) end end end --log.print("-end- getImageDirectories ") return dcimListend--[[ Loops through DCIM dirs and creates list of files ]]function disk.getImageList() local imgTable = {} local dcimList = disk.getImageDirectories() local dirCount = table.getn(dcimList) local i = 0 while ( dirCount ~= i) do i = i + 1 --log.print("A/DCIM/"..dcimList[i].."\n") local imgDirList = os.listdir("A/DCIM/"..dcimList[i], false) local imgCount = table.getn(imgDirList) --log.print("imgCount:"..imgCount) table.sort(imgDirList) local a = 0 while (imgCount ~= a) do a = a + 1 --log.print("A/DCIM/"..dcimList[i].."/"..imgDirList[a]) table.insert(imgTable,"A/DCIM/"..dcimList[i].."/"..imgDirList[a]) end end return imgTableend--[[Mass rename of movie files to .JPG, thumbnails are not touched.Takes advantage of the fact that movie files are usually significantly larger than images, and their full filenames will usually fit into a moderate amount of RAM.]]newPicList = disk.filterImageFiles(".AVI")for index,oldName in ipairs(newPicList) do namepart = string.sub(oldName,1,24) os.rename(oldName,namepart..".JPG")end
Started by oversky Feature Requests
Started by elektro255 « 1 2 » General Discussion and Assistance
Started by outslider « 1 2 ... 15 16 » General Discussion and Assistance
Started by rvk Script Writing
Started by otosclerosi Completed and Working Scripts