148
C H A P T E R 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])
Содержание Camera
Страница 1: ......
Страница 2: ...The Canon Camera Hackers Manual ...
Страница 3: ......
Страница 4: ...Berthold Daum The Canon Camera Hackers Manual Teach Your Camera New Tricks ...
Страница 19: ...10 CH APTER 2 Cameras and Operating Systems ...
Страница 25: ...16 CH APTER 3 ...
Страница 85: ...76 CH APTER 4 Teach Your Camera New Tricks ...
Страница 213: ...204 CH APTER 6 ...
Страница 253: ...244 AP PENDIX ...