jcuster
09-26-2008, 10:55 AM
The story is I found some cool VB scripts that burn to CD or DVD. What I would like to do is have SUF use these scripts to burn a backup of the My Documents folder to a DVD(s) or CD(s).
What I'm having trouble with is getting My documents into a set of temp folders for burning.
Like Disk1, Disk2, Disk3.
The code that I'm currently using for another application that I would just like to modify is as follows;
function COPYCB(Source,Destination,Copied,Total)
DlgProgressBar.SetPos(CTRL_PROGRESS_BAR_02, (nfl / nflcnt) * 100);
return true; --continue copying
end
function copyfls(Srce,Dst,MDerror)
--set source and destination values, then 'find files' to table
g_FolderSize = 0;TCOPIED = 0;T_str = " ";
local Ssrce = Srce;
local Sdest = Dst;
local l25 = false
local l50 = false
local l75 = false
tfldrs = Folder.Find(Ssrce, "*", true, nil);
tfiles = {}
local tfiles = File.Find(Ssrce, "*.*", true, false, nil, OnFileFound);
if tfiles then
if (not Folder.DoesExist(Sdest)) then
Folder.Create(Sdest); --create Destination 'Parent Folder
end
if tfldrs then
LnSsrce = String.Length(Ssrce);
Allfldrs = Table.Count(tfldrs);
for x=1, Allfldrs do
tst = String.Mid(tfldrs[x], LnSsrce, -1);
tsttf = Folder.DoesExist(Sdest..tst);
if testtf ~= true then
Folder.Create(Sdest..tst);
end
end
end
local nlngth = String.Length(Ssrce); nflcnt = Table.Count(tfiles); destdir = {};
--cycle and copy each file , calling callback function named: COPYCB()
for n=1,nflcnt do
nfl = n; local dest = String.Mid(tfiles[n], nlngth +1, -1);
--note: it may be worth considering the File.Install action instead of file.copy
File.Copy(tfiles[n], Sdest..dest, true, true, true, true, COPYCB);
MDerror = Application.GetLastError();
--Jerry's Update Progress Bar
Pcnt = Math.Round((nfl / nflcnt * 100), 0)
if Pcnt == 25 and l25 == false then
DlgProgressBar.SetPos(CTRL_PROGRESS_BAR_01,(DlgPro gressBar.GetPos(CTRL_PROGRESS_BAR_01)+ 1));
l25 = true
end
if Pcnt == 50 and l50 == false then
DlgProgressBar.SetPos(CTRL_PROGRESS_BAR_01,(DlgPro gressBar.GetPos(CTRL_PROGRESS_BAR_01)+ 1));
l50 = true
end
if Pcnt == 75 and l75 == false then
DlgProgressBar.SetPos(CTRL_PROGRESS_BAR_01,(DlgPro gressBar.GetPos(CTRL_PROGRESS_BAR_01)+ 1));
l75 = true
end
gpos = DlgProgressBar.GetPos(CTRL_PROGRESS_BAR_01)
shrt = String.AbbreviateFilePath(tfiles[n], 72);
DlgStaticText.SetProperties(CTRL_STATICTEXT_LABEL_ 04,{Text = shrt.." "});
DlgProgressBar.SetProperties(CTRL_PROGRESS_BAR_02, {Text = Pcnt.."%"});
tpnct = Math.Round(gpos * 5,0)
if gpos == 0 then
DlgProgressBar.SetProperties(CTRL_PROGRESS_BAR_01, {Text = "0%"});
else
DlgProgressBar.SetProperties(CTRL_PROGRESS_BAR_01, {Text = tpnct.."%"});
end
end
end
nflcnt = nil; nfl = nil; --clear the two global values
end
PS. I think most of this code came from Jassing, thanks it works great for copying from entire location to another.
What I'm having trouble with is getting My documents into a set of temp folders for burning.
Like Disk1, Disk2, Disk3.
The code that I'm currently using for another application that I would just like to modify is as follows;
function COPYCB(Source,Destination,Copied,Total)
DlgProgressBar.SetPos(CTRL_PROGRESS_BAR_02, (nfl / nflcnt) * 100);
return true; --continue copying
end
function copyfls(Srce,Dst,MDerror)
--set source and destination values, then 'find files' to table
g_FolderSize = 0;TCOPIED = 0;T_str = " ";
local Ssrce = Srce;
local Sdest = Dst;
local l25 = false
local l50 = false
local l75 = false
tfldrs = Folder.Find(Ssrce, "*", true, nil);
tfiles = {}
local tfiles = File.Find(Ssrce, "*.*", true, false, nil, OnFileFound);
if tfiles then
if (not Folder.DoesExist(Sdest)) then
Folder.Create(Sdest); --create Destination 'Parent Folder
end
if tfldrs then
LnSsrce = String.Length(Ssrce);
Allfldrs = Table.Count(tfldrs);
for x=1, Allfldrs do
tst = String.Mid(tfldrs[x], LnSsrce, -1);
tsttf = Folder.DoesExist(Sdest..tst);
if testtf ~= true then
Folder.Create(Sdest..tst);
end
end
end
local nlngth = String.Length(Ssrce); nflcnt = Table.Count(tfiles); destdir = {};
--cycle and copy each file , calling callback function named: COPYCB()
for n=1,nflcnt do
nfl = n; local dest = String.Mid(tfiles[n], nlngth +1, -1);
--note: it may be worth considering the File.Install action instead of file.copy
File.Copy(tfiles[n], Sdest..dest, true, true, true, true, COPYCB);
MDerror = Application.GetLastError();
--Jerry's Update Progress Bar
Pcnt = Math.Round((nfl / nflcnt * 100), 0)
if Pcnt == 25 and l25 == false then
DlgProgressBar.SetPos(CTRL_PROGRESS_BAR_01,(DlgPro gressBar.GetPos(CTRL_PROGRESS_BAR_01)+ 1));
l25 = true
end
if Pcnt == 50 and l50 == false then
DlgProgressBar.SetPos(CTRL_PROGRESS_BAR_01,(DlgPro gressBar.GetPos(CTRL_PROGRESS_BAR_01)+ 1));
l50 = true
end
if Pcnt == 75 and l75 == false then
DlgProgressBar.SetPos(CTRL_PROGRESS_BAR_01,(DlgPro gressBar.GetPos(CTRL_PROGRESS_BAR_01)+ 1));
l75 = true
end
gpos = DlgProgressBar.GetPos(CTRL_PROGRESS_BAR_01)
shrt = String.AbbreviateFilePath(tfiles[n], 72);
DlgStaticText.SetProperties(CTRL_STATICTEXT_LABEL_ 04,{Text = shrt.." "});
DlgProgressBar.SetProperties(CTRL_PROGRESS_BAR_02, {Text = Pcnt.."%"});
tpnct = Math.Round(gpos * 5,0)
if gpos == 0 then
DlgProgressBar.SetProperties(CTRL_PROGRESS_BAR_01, {Text = "0%"});
else
DlgProgressBar.SetProperties(CTRL_PROGRESS_BAR_01, {Text = tpnct.."%"});
end
end
end
nflcnt = nil; nfl = nil; --clear the two global values
end
PS. I think most of this code came from Jassing, thanks it works great for copying from entire location to another.