EasyManua.ls Logo

Canon Camera - Page 157

Canon Camera
257 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
148 CHAPTER 5 Scripting
In case of success, we increment the image counter s.
function renameFile(path, file)
oldname = path..file
local t = os.stat(oldname)
if t["is_file"] then
newname =
path..prefix..s..suffix
t = os.stat(newname)
if t then
error(
oldname.." already exists")
end
r, msg = os.rename(
oldname, newname)
if not r then
error(msg)
end
s = s + 1
end
end
The following code is the main script part. It first lets the user select a
subfolder of DCIM/. It does so by fetching the members of the root directory
and prompting the user with the subfolder names. The user can navigate
with the
LEFT and RIGHT buttons to the subfolder whose files shall be re-
named. The user selects the subfolder by pressing
FUNC/SET. The button
DISP is used to abort.
-- folder selection
files, msg =
os.listdir(root,false)
if not files then
error(msg)
elseif not files[1] then
error("No image folders")
end
i = 1
while true do
cls()
print("Press SET to select")
print("LEFT, RIGHT to scroll")
print("DISP to abort")
print("Folder: "..files[i])

Table of Contents

Related product manuals