Indigo Rose Software
  #1  
Old 09-26-2008
jcuster jcuster is offline
Indigo Rose Customer
 
Join Date: Jul 2001
Location: Harrisburg, PA , USA
Posts: 91
Copying My Documents

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;

Code:
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,(DlgProgressBar.GetPos(CTRL_PROGRESS_BAR_01)+ 1));
		l25 = true
	end
	if Pcnt == 50 and l50 == false then 
		DlgProgressBar.SetPos(CTRL_PROGRESS_BAR_01,(DlgProgressBar.GetPos(CTRL_PROGRESS_BAR_01)+ 1));
		l50 = true
	end
	if Pcnt == 75 and l75 == false then 
		DlgProgressBar.SetPos(CTRL_PROGRESS_BAR_01,(DlgProgressBar.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.
Reply With Quote
  #2  
Old 09-26-2008
jassing's Avatar
jassing jassing is offline
Indigo Rose Customer
 
Join Date: Jan 2001
Location: Anderson Island, WA, USA
Posts: 1,901
so you want to copy "a folder" to "x# of folders" such that each 'x' folder is at most z megs?

It's definately doable -- the simple method is to keep a running total of each file that is copied; when the next file to be copied would go over Z; then you increment X and create a new folder; and reset the total count of bytes.

The tricky part would be to optimize the copy routine to maximize the space usage in each folder, such that you got as close to Z (w/o going over) as possible...
__________________
Reply With Quote
  #3  
Old 09-27-2008
jcuster jcuster is offline
Indigo Rose Customer
 
Join Date: Jul 2001
Location: Harrisburg, PA , USA
Posts: 91
Quote:
Originally Posted by jassing View Post
so you want to copy "a folder" to "x# of folders" such that each 'x' folder is at most z megs?

It's definately doable -- the simple method is to keep a running total of each file that is copied; when the next file to be copied would go over Z; then you increment X and create a new folder; and reset the total count of bytes.

The tricky part would be to optimize the copy routine to maximize the space usage in each folder, such that you got as close to Z (w/o going over) as possible...
Let me specify further. This routine Creates Folders seperatly from the copy routine.

Even before I get into the X and z portion I think I need to combine the "create Folder routine" and the "Copy files routine." I'm having a real bear of a time getting the tfldr and tfiles to match.
Reply With Quote
  #4  
Old 09-27-2008
jassing's Avatar
jassing jassing is offline
Indigo Rose Customer
 
Join Date: Jan 2001
Location: Anderson Island, WA, USA
Posts: 1,901
Quote:
Originally Posted by jcuster View Post
I'm having a real bear of a time getting the tfldr and tfiles to match.
I'm not clear on what you're after then...sorry.
__________________
Reply With Quote
  #5  
Old 09-27-2008
jcuster jcuster is offline
Indigo Rose Customer
 
Join Date: Jul 2001
Location: Harrisburg, PA , USA
Posts: 91
Further explanation

Let me explain more

This part of the funtcion creates the folders for the destination, Sdest
Code:
	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
This part copies the files to folders in Sdest.

Code:
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,(DlgProgressBar.GetPos(CTRL_PROGRESS_BAR_01)+ 1));
		l25 = true
	end
	if Pcnt == 50 and l50 == false then 
		DlgProgressBar.SetPos(CTRL_PROGRESS_BAR_01,(DlgProgressBar.GetPos(CTRL_PROGRESS_BAR_01)+ 1));
		l50 = true
	end
	if Pcnt == 75 and l75 == false then 
		DlgProgressBar.SetPos(CTRL_PROGRESS_BAR_01,(DlgProgressBar.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
For instance I need to
1 Find the files
2 Get the file size
3 Increment the Size counter
4 Check the size counter against the disk size
5 Either increment the destination or keep it the same
6 (resetting the size counter if needed)

Now heres the tricky part the creation of the folders is separate from the copy file process

7 Create the folder
8 Copy the File
9 Repeat 2-8 until complete

Because of Step 7 and 8 I need to change the routine. Or did I misinterrupt the logic?

I think this routine can be modded to create the folder just before the file is copied but I'm not sure how?
Reply With Quote
  #6  
Old 09-27-2008
jassing's Avatar
jassing jassing is offline
Indigo Rose Customer
 
Join Date: Jan 2001
Location: Anderson Island, WA, USA
Posts: 1,901
Quote:
Originally Posted by jcuster View Post
Or did I misinterrupt the logic?
well; I'm not sure -- but the obvious error is in your variables...

Code:
tsttf = Folder.DoesExist(Sdest..tst);
if testtf ~= true then
__________________
Reply With Quote
  #7  
Old 09-30-2008
jcuster jcuster is offline
Indigo Rose Customer
 
Join Date: Jul 2001
Location: Harrisburg, PA , USA
Posts: 91
I got it

I had to use the following code to create folders with the files. I had to make one table with both empty folders and files. Next I had to Identify the folders with a trailing "\\", thus allowing me to identify it later and create the folders in the destination.

Code:
tfiles = {};tfldrs = {}

tfldrs = Folder.Find(Ssrce, "*", true, nil);
local tmptfiles = File.Find(Ssrce, "*.*", true, true, nil, OnFileFound);
for x,y in tfldrs do
Table.Insert(tfiles, Table.Count(tfiles)+1, y.."\\");
end
for x,y in tmptfiles do
Table.Insert(tfiles, Table.Count(tfiles)+1, y);
end
Table.Sort(tfiles, nil)

Code:
		tst = String.Right(tfiles[n] ,1 );
		if tst == "\\" then
			Folder.Create(Sdest..dest)
		end
Now I can work on changing the destination folder, if it gets to a certian size..
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Common Documents Folder wunder Setup Factory 7.0 Discussion 6 03-18-2008 11:59 AM
How can I protect my program and CD from illegal copying adnan AutoPlay Media Studio 6.0 4 02-13-2007 05:40 AM
Need help with scripting cd-rom for text documents Ed Stanley AutoPlay Media Studio 6.0 0 05-10-2006 04:47 PM
CD-R or CD-ROM can now be protected from Illegal Copying and Use mike41 AutoPlay Media Studio 5.0 2 10-15-2004 09:05 AM
Install documents as archieve Fleaby Setup Factory 6.0 2 07-24-2003 10:39 PM


All times are GMT -6. The time now is 08:09 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software