Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2001
    Location
    Harrisburg, PA , USA
    Posts
    114

    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.

  2. #2
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    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...


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  3. #3
    Join Date
    Jul 2001
    Location
    Harrisburg, PA , USA
    Posts
    114
    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.

  4. #4
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    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.


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  5. #5
    Join Date
    Jul 2001
    Location
    Harrisburg, PA , USA
    Posts
    114

    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?

  6. #6
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    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


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  7. #7
    Join Date
    Jul 2001
    Location
    Harrisburg, PA , USA
    Posts
    114

    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..

Similar Threads

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts