PDA

View Full Version : Function to Copy a Folder, Sub-folders and files



Worm
03-04-2004, 03:01 PM
Here is the code...

Sample Call: Copies the content of D:\ to C:\Program Files\My App


if CopyFolder("D:\\", "C:\\Program Files\\My App") == 0 then
result = Dialog.Message("Folder Copy", "The folder has been successfully copied!", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
else
result = Dialog.Message("Folder Copy", "There was an error copying the folder.", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
end



Global Function


function CopyFolder(sSource, sDestination)
local m_sFolder;
local m_FoundFolder;
local error;

--Find all the folders and sub-Folders
--results are stored in the table m_tblFolders
m_tblFolders = Folder.Find(sSource, "*", true, nil);

--if our destination folder does not have the
--backslash as the last character, add it
if String.Right(sDestination, 1) ~= "\\" then
sDestination = sDestination .. "\\";
end

--m_tblFolders will be nil if there are no folders
if m_tblFolders ~= nil then
--enumerate through the found folders
for n, m_FoundFolder in m_tblFolders do
--replace the source's path with the destination's path
m_sFolder = String.Replace(m_FoundFolder, sSource, sDestination, false);
--create the folder
Folder.Create(m_sFolder);
error = Application.GetLastError();
if (error ~= 0) then
--set n to value to exit FOR loop
n = Table.Count(m_tblFolders)
end
end
end

--if no errors occurred, copy the files
if (error == 0) then
--show the status dialog
StatusDlg.Show(MB_ICONNONE, false);
--copy all files from the source folder, with recurse.
File.Copy(sSource .. "\\*.*", sDestination, true, true, false, true, nil);
--hide the status dialog
StatusDlg.Hide();
error = Application.GetLastError();
end

--clean up
m_tblFolders = nil;
return error;
end

willfreer
08-17-2004, 01:57 PM
I believe this is what I am looking for but I can't get it to work.
I have a page in AutoPlay with an option to click on file to copy to computer. When the person selects a file, I would like the screen "where would you like to save folder?" to popup. and when the person selects where they would like to save it, the linked folder saves there into that spot. Is there such a code? Will

aeisenbe
08-18-2004, 09:27 AM
I work with Willie, who asked this and we are still having a problem. It is really about understanding how to use your code. We are newbie programmers (more designers). We copied and pasted your code into AMS 5, but it gives us an error that says copyfolder is nil.

What are we missing? How do you add it to AMS 5 and what part of the code do we change to make it work? Sorry for seeming so dumb, but we want to learn and have few resources (programmers) to help us understand. If you could walk us through how to add your code in AMS 5 and how to alter it to do what we want, that would help us learn a lot in a short period and deliver our product. Thanks so much.

Alan Eisenberg

Worm
08-18-2004, 09:56 AM
From your post it looks like you want to copy a single file. If that's the case, this function is pure overkill. I think you're looking for something more like this.



--ask for the file to copy
tblFile = Dialog.FileBrowse(true, "Select the file to copy", _DesktopFolder, "All Files (*.*)|*.*|", "", "", false, true)

--if the user didn't cancel
if tblFile[1] ~= "CANCEL" then
--Get the folder to copy the file to
sFolder = Dialog.FolderBrowse("Please Select the folder to copy the file to.", _DesktopFolder)
--if the user didn't cancel
if sFolder ~= "CANCEL" then
--copy the file to the folder
File.Copy(tblFile[1], sFolder, false, true, true, false, nil)
end
end




I believe this is what I am looking for but I can't get it to work.
I have a page in AutoPlay with an option to click on file to copy to computer. When the person selects a file, I would like the screen "where would you like to save folder?" to popup. and when the person selects where they would like to save it, the linked folder saves there into that spot. Is there such a code? Will

aeisenbe
08-18-2004, 10:05 AM
No. Actually we want to copy a whole folder that is on the CD and put it on the user's computer. So, we do want the function where we program which folder to copy and have the user specify where they want to put it.

I believe that is the code you have. We just don't know how to apply and alter the code in AMS 5. Can you walk me through that (i.e. - First copy the top code, then...etc.)

Thank you again for your help.

Worm
08-18-2004, 10:24 AM
Here's an example to look at.

aeisenbe
08-18-2004, 10:32 AM
Thank you so much for this. It is almost exactly what we need. But, we know what the source folder is, we just need to specify the destination folder.

What do we alter to make that work? Again, thanks for helping teach us how. This was a big help.

Alan

Worm
08-18-2004, 10:38 AM
Change the code in the label to this:



--get the destination folder
sDestFolder = Dialog.FolderBrowse("Select the Destination Folder", _DesktopFolder)
--see if the user cancelled
if sDestFolder ~= "CANCEL" then
--initiate the copy
--CopyFolder is function in the Global Functions area of the project (Alt-D-F)
if CopyFolder(_SourceFolder .. "\\Your\\Path\\Here", sDestFolder) == 0 then
result = Dialog.Message("Folder Copy", "The folder has been successfully copied!", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
else
result = Dialog.Message("Folder Copy", "There was an error copying the folder.", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
end
end



Thank you so much for this. It is almost exactly what we need. But, we know what the source folder is, we just need to specify the destination folder.

What do we alter to make that work? Again, thanks for helping teach us how. This was a big help.

Alan

aeisenbe
08-18-2004, 11:07 AM
OK, last question. Will this work in Preview mode in AMS 5 or only once it's built. It's not working in Preview mode, but I get the impression it will have to build first before it works. It gives me an "error copying the folder" message. Is that right?

Alan Eisenberg

Worm
08-18-2004, 11:16 AM
It should work in either situation.

Could you post the snippet of code that is giving you problems? It'd be easier for me to help, if I weren't guessing at what you are attempting to accomplish.

aeisenbe
08-18-2004, 11:24 AM
Actually I got it to work. The problem was seems to be that the source and destination folders I was specifying were both C: drive folders. For example, if I said:
---------------------------------------------
if CopyFolder("C:\\test", "C:\\Documents and Settings\fred\Desktop\test") == 0 then
result = Dialog.Message("Folder Copy", "The folder has been successfully copied!", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
else
result = Dialog.Message("Folder Copy", "There was an error copying the folder.", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
end
---------------------------------------------------

Then I would get an error message. If I changed it to a source file at a different location:

---------------------------------------------
if CopyFolder("D:\\test", "C:\\Documents and Settings\fred\Desktop\test") == 0 then
result = Dialog.Message("Folder Copy", "The folder has been successfully copied!", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
else
result = Dialog.Message("Folder Copy", "There was an error copying the folder.", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
end
---------------------------------------------------

Then it will work. It doesn't seem to like to move things around on the same level. Of course, my real case would be a folder on the CD, not on the C: drive, I was only doing this as a test.

I still do have one outstanding question (of course). The code you gave me to my question before asks for the Source folder, but I can hard-code the destination. I wanted the opposite. I know what Source folder I want to copy from my CD, but I want the user to specify where on their hard drive they want to put it. I can put in the path for the source folder myself. Do you have the code for that.

So what I want is for the user to be prompted to place a folder that I have already chosen somewhere on their hard drive. I don't need them to be asked what source folder they want to pick. If you've got that handy, that would be it. Otherwise I thank you so much and you have saved the day for us.

Worm
08-18-2004, 11:30 AM
I've used this function many times and never had issues when copying to the same drive. I'd guess that one of the folders doesn't exist. The function needs both the source and destination folders to already exist.

I posted the code to ask for the destination only above, but here it is again.


--get the destination folder
sDestFolder = Dialog.FolderBrowse("Select the Destination Folder", _DesktopFolder)
--see if the user cancelled
if sDestFolder ~= "CANCEL" then
--initiate the copy
--CopyFolder is function in the Global Functions area of the project (Alt-D-F)
if CopyFolder("C:\\Your\\Path\\Here", sDestFolder) == 0 then
result = Dialog.Message("Folder Copy", "The folder has been successfully copied!", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
else
result = Dialog.Message("Folder Copy", "There was an error copying the folder.", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
end
end

Brett
08-18-2004, 11:48 AM
Also, make sure you are escaping your slashes. Instead of:

"C:\\Documents and Settings\fred\Desktop\test"

use:

"C:\\Documents and Settings\\fred\\Desktop\\test"

Worm
08-18-2004, 11:50 AM
Nice catch Brett, I thought I'd looked for that.

willfreer
08-19-2004, 11:35 AM
Alan and I keep geting the message "There was an error copying the folder." and we can't find where the code breakdowns. This is what we have.

--get the destination folder
sDestFolder = Dialog.FolderBrowse("Select the Destination Folder", _DesktopFolder)
--see if the user cancelled
if sDestFolder ~= "CANCEL" then
--initiate the copy
--CopyFolder is function in the Global Functions area of the project (Alt-D-F)
if CopyFolder("\\Media\\Users\\Alan\\AV Video Article", sDestFolder) == 0 then
result = Dialog.Message("Folder Copy", "The folder has been successfully copied!", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
else
result = Dialog.Message("Folder Copy", "There was an error copying the folder.", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
end
end


See anything that stands out? Thanks for all your help.

Brett
08-19-2004, 12:13 PM
What is this folder:

"\\Media\\Users\\Alan\\AV Video Article"

where is it located? Why not just include a full reference to it?

Worm
08-19-2004, 01:57 PM
You need to supply the full path to the source folder.

willfreer
08-19-2004, 02:38 PM
Let's say the intended source folder will be the CD Drive (D: for us) when the project is delivered to the customer.

So I put another CD in the CD drive with a folder called "Willie MMU" on the top level of the CD.

so my source line looks like this:

if CopyFolder("D:\\Willie MMU", sDestFolder) == 0 then

It seems like it doesn't initiate the copy command. From there it goes to the

"There was an error copying the folder."

Maybe I need to change something in my Global Functions?

Thanks, Willie

rhosk
08-19-2004, 03:16 PM
Hi Willie,

Instead of going back and forth here, why don't you post your entire code (dealing with the copy folder action) relating to the function and I guarantee you that these experts will pin-point the problem. Just perusing the posts, I think you may need to use some global variables. Without knowing the exact code that you're using, it's hard to speculate what the problem is ;)

If your syntax is off by a single character, errors are inevitable.

SUF6NEWBIE
08-19-2004, 07:23 PM
Hi all, I also have a script that will copy a target folder and sub tree
to nominated location etc...

I'll remove my APp specific code and post when I can...

I have one 'Copy Issue' to get around incase(it happens !) the User
Removes the CD Media before Copy function has completed..

If the OS catches CD access error Before my error handling(also using the
progress plugin) then APP FREEZE !

I get an error (AC Runtime error accessing unamed file)
this seems to be an AMS error and Not an OS error message.

I have a 'Cancel' button which works OK but covering the User remove
Source scenario is appearing to be a tricky one...

Any ideas...sure without my code at the moment, its asking a bit...

Perhaps BRETT, you could enlighten me regarding the:
(AC Runtime error accessing unamed file)

BTW copying from Root of a CD is a tricky one, I have a soultion for this...

Is there a way to test wether the CD tray is open ?

TKS

Brett
08-20-2004, 08:14 AM
Perhaps BRETT, you could enlighten me regarding the:
(AC Runtime error accessing unamed file)

That means that the data file created at build-time is corrupted somehow. That is our programs way of saying, "hey, I'm not getting the data that I am expecting here!"

I would reccomend and uninstall, reboot, reinstall and rebuild. Also make sure that you are using the most recent version of the software.

willfreer
08-20-2004, 12:02 PM
Hi Worm. We finally got the script to work. It seems that the source folder has to have one more folder in it, with the files that you wish to save. In other words, a source folder with files in it gives and error message. But a folder within the source folder with files in it works.

Thanks for all of your help and hard work. Hopefully someone else can use this code also.

Will

SUF6NEWBIE
08-20-2004, 01:17 PM
TKS BRETT....I'll try the 'Rebuild' scenario as a last resort

..the interesting thing is the 'AC Runtime error' only shows
during the Copy proccess and only if the 'Source Media' is removed
prematurely...if copy proccess is completed..all other related
coding, my functions etc..working fine..everytime.

(I am running from a published SFX)

built the App with AMSPro 5.0.0.5

I am using some string manipulation during my 'copy function'
..possibility if 'Source is removed the Table that is cycled through
(regardless of builtin checking of a known file on the 'Source.. before
and after each file is copied.. via the Table) ..may be triggering the
(error accessing unnamed file) 5 out of ten times my error handling
will deal with premature Source removal...otherwise 'run home to mumma'

Intrigued
08-24-2004, 05:29 PM
What would be the best approach to modifying the function to include the entire folder, rather than just copying the contents of the folder?

For instance, when I use the function:


CopyFolder("c:\\test1\\folder1","c:\\test2");

I just get the contents of folder1 inside of c:\test2. What I'd like is c:\test2\folder1 to exist.

Any thoughts?
Check and see if this works for you. I hope I am not off the path.


-- Create folder 'folder1' which is inside folder 'test1'
Folder.Create("C:\\test1\\folder1");

-- Create folder 'folder2' which is inside folder 'test2'
Folder.Create("C:\\test2\\folder1");

-- Create an empty table that will eventually hold all the file paths in the 'folder to be copied'
tblFiles = {};

-- Create a variable to hold the (table) of file paths from the 'copied from' folder
tblfiles_found = File.Find("C:\\test1\\folder1", '*.*', true, true, nil);

-- Get the total amount (number) of files found, used as an upper limit on our 'for..do' loop to come
amount = Table.Count(tblfiles_found);

-- for..do loop that will now populate the previously empty table (tblFiles) with the 'copied from' file paths
-- and then there is the file.copy function that will copy the files into the new 'test2\\folder1' created
for n=1, amount do
Table.Insert(tblFiles, n, tblfiles_found[n]);

File.Copy(tblFiles[n], "C:\\test2\\folder1", true, true, true, false, nil);

end

Note: I see you wanted a modification of the function. This is just a hard coded way, to see how such works, outside of a 'function' environment.

Sincerely,

Intrigued
08-31-2004, 06:39 PM
I see your post Buffman. I am busy tonight working through a project for a client.

If someone else can chime in with a function that would help out Buffman that would be appreciated. I know some of you guys/gals are function'ators! (grin)

For me... I have to think a bit on the functions and tonight I wish I had more time. If no one answers I will get back on this matter as soon as I can.

Thank you for your patience Buffman.

Sincerely,

JimS
09-01-2004, 12:25 AM
If I understand this thread correctly, you do know, and are hard coding in the source path, it is the destination path that will vary from user to user.

That means you know the name of folder1, so just concatenate it to the destination folder.

CopyFolder("c:\\test1\\folder1", sDestFolder)

becomes

CopyFolder("c:\\test1\\folder1", sDestFolder .."\\folder1\\")


I tested this code, and it works. If I misunderstood about you knowing the name of folder1, we can figure that one out too. Post back if this doesn’t fix it for you.

csd214
09-01-2004, 02:48 AM
How do I break this up to just get 'folder1'? I have increasing difficulty doing this especially when going more than one level deep.
I haven’t fully read all the posts in this thread, but I assume the scenario is:
You have a variable with “test1\folder1” and you want to get just “folder1”. The code below possibly does what you want? (Sorry if I have misunderstood the issue.) This is a common task I have performed several times in Setup Factory 6 (without the table function). I then used a while loop to read the string finding all the backslashes. Now Setup Factory 7 uses the Lua script engine. Maybe I should create a generic function to split the string?


cFullPath = "D:\\Test\\Folder 2\\Folder 3\\Something.txt";
tblPath = String.SplitPath(cFullPath);
cFolder = tblPath.Folder; -- cFolder value: \Test\Folder 2\Folder 3\
-- we want to split into "Test", "Folder 2" and "Folder 3"
cFolder = String.TrimRight(cFolder, "\\"); -- remove the ending backslash
cFolder = String.TrimLeft(cFolder, "\\"); -- remove the leading backslash
-- now we have: Test\Folder 2\Folder 3

-- we want to use this string to create a table
-- this is one way to perform the task:

-- replace the backslashes with "\r\n" (CR and LF)
cFolder = String.Replace(cFolder, "\\", "\r\n", false); -- = Test,Folder 2,Folder 3 on three separate lines
TextFile.WriteFromString("file.tmp", cFolder, false); -- write to text file
tblElements = TextFile.ReadToTable("file.tmp"); -- read text file to table
File.Delete("file.tmp", false, false, false, nil); -- delete the text file

-- now we have a table that could have been created with this action:
--tblElements = {"Test", "Folder 2", "Folder 3"};

cMsg = "";
for x,y in tblElements do
cMsg = cMsg.."Element "..x.." = "..y.."\r\n";
end
Dialog.Message("Your Folder", cMsg);

-- to display the last element
nTblCount = Table.Count(tblElements);
Dialog.Message("Last Subfolder", tblElements[nTblCount]);

Intrigued
09-02-2004, 12:12 PM
Thank you csd214!

Sincerely,

willfreer
12-10-2004, 01:49 PM
Hi Worm, A few months back you were helping me and my cowork with problem a "copy folder to (destination) problem. We got it to work thanks to you but now when it is time to use it. We found a few problems.

1st. If the user comes back later and tries to copy the same folder the desktop by accident. He gets an error failed message.

2nd. We have a list of about 6 items with that action on it. When we open Aoutoplay, the 1st one we click on will work, and then the action will not work no more.

Any suggestions would be greatly appreciated.

Willie

Worm
12-11-2004, 08:01 PM
If I may, I'd like to send you to this thread. I wrote a DLL that handles this very well. I simply don't have time to go through the code right now, and don't want to leave you hanging.

http://www.indigorose.com/forums/showthread.php?t=6402&highlight=folder+actions

willfreer
12-13-2004, 07:10 AM
Thanks Worm,

2 questions.
1. Where do I put the DLL (in actions on the button, or in global? not sure)

2. What part of the DLL do I change for each folder that I would like to have copied to the users computer. Since each button will have a difference source folder that the user would like to have copied to their computer.

Thanks, let me know if this doesn't make any sense.

Will

Worm
12-13-2004, 11:21 AM
--Enter global declarations and functions here...
function CopyFolder(sSource, sDestination)
local m_sFolder;
local m_FoundFolder;
local error;

--Find all the folders and sub-Folders
--results are stored in the table m_tblFolders
m_tblFolders = Folder.Find(sSource, "*", true, nil);

--if our destination folder does not have the
--backslash as the last character, add it
if String.Right(sDestination, 1) ~= "\\" then
sDestination = sDestination .. "\\";
end

--m_tblFolders will be nil if there are no folders
if m_tblFolders ~= nil then
--enumerate through the found folders
for n, m_FoundFolder in m_tblFolders do
--replace the source's path with the destination's path
m_sFolder = String.Replace(m_FoundFolder, sSource, sDestination, false);
--create the folder
Folder.Create(m_sFolder);
error = Application.GetLastError();
if (error ~= 0) then
--set n to value to exit FOR loop
n = Table.Count(m_tblFolders)
end
end
else
error = 0
end

--if no errors occurred, copy the files
if (error == 0) then
--show the status dialog
StatusDlg.Show(MB_ICONNONE, false);
--copy all files from the source folder, with recurse.
File.Copy(sSource .. "\\*.*", sDestination, true, true, false, true, nil);
--hide the status dialog
StatusDlg.Hide();
error = Application.GetLastError();
end

--clean up
m_tblFolders = nil;
return error;
end

willfreer
12-13-2004, 12:20 PM
that's it!!!!


Thanks alot, Now it will be good practice for me to compare the 2 codes to see were the 1st one was wrong, thanks again,

Willie

Worm
12-13-2004, 12:23 PM
Basically, when it was run the first time, it creates the folders. When you would run it the second time, it would error because the folders already existed. I changed the code to allow for the folder to exist already.

It should work for a folder without subfolder now too.

Intrigued
12-13-2004, 12:34 PM
Thanks from me as well Worm!

I updated this offering on amsuser.com just now as well.

Sincerely,

Worm
12-13-2004, 12:36 PM
Hey, you're back. Missed you there for a couple weeks or so.

Intrigued
12-13-2004, 12:38 PM
Well, I had some personal problems (no jokes :p) and of late I have been pounding the Flash MX 2004 book(s) I bought a couple months ago.

Thansk Worm,

Worm
12-13-2004, 12:44 PM
Glad to see you have prevailed. Flash, eh? I guess I'll have to keep an eye on whatever you post. That is one realm I haven't gotten into.

csd214
12-13-2004, 02:00 PM
Intrigued, glad you're back. "I'll follow you."

Greetings from Norway. Happy Holliday. :)

Intrigued
12-13-2004, 02:35 PM
Roger Worm.

Thanks csd214!

Intrigued
12-13-2004, 02:53 PM
Here is a taste of what I have been learning.

This is a .zip file that contains a .fla (file in raw, editable form) and the .swf files.

This is an example of how to use some of the drawing functions in Flash MX 2004 (for this example).

The next level will be utilize the FSCommand with regards to AMS, Flash and these sort of .swf files!

I'm stoked! (excited those trying to understand us English speaker folks).

Here is the link:


Drawing (Flash MX 2004) (http://amsuser.com/ams/examples/Drawing.zip)

Sincerely,

tucker
05-18-2005, 08:59 AM
function CopyFolder(sSource, sDestination)

so after playing with this global function above, i still cannot get a folder copy going. I dont need any dialog which is why I ommitted most of the other lines.

I thought it would look like like:
copyfolder ("\\source path here\\", "\\destination path here\\")

but maybe im missing a crucial component. Go easy on me, im still learning all of this :)

tucker
06-14-2005, 10:03 AM
I hate to keep beating up the same subject but it seems that I have gotten a grasp of this copy folder function, but I have realize I have no need to display that it actually did do a successful or unsuccessful copy. So how much can I delete off the command but i keep getting errors when I try figure out how much it is I have to delete.
How much of the below tag needs to be romoved in order for a dialog "NOT" to pop up:


--Get the source folder
sSourceFolder = ("C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Roxio Easy CD and DVD Creator 6")
--See if the user cancelled
if sSourceFolder ~= "CANCEL" then
--get the destination folder
sDestFolder = ("C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\IntelApps\\Roxio Easy CD and DVD Creator 6")
--see if the user cancelled
if sDestFolder ~= "CANCEL" then
--initiate the copy
--CopyFolder is function in the Global Functions area of the project (Alt-D-F)
if CopyFolder(sSourceFolder, sDestFolder) == 0 then
result = Dialog.Message("Folder Copy", "The folder has been successfully copied!", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
else
result = Dialog.Message("Folder Copy", "There was an error copying the folder.", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
end
end
end

tucker
06-15-2005, 06:33 AM
No one knows?

csd214
06-15-2005, 06:43 AM
If I have understood correctly

--Get the source folder
sSourceFolder = ("C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Roxio Easy CD and DVD Creator 6")
--See if the user cancelled
if sSourceFolder ~= "CANCEL" then
--get the destination folder
sDestFolder = ("C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\IntelApps\\Roxio Easy CD and DVD Creator 6")
--see if the user cancelled
if sDestFolder ~= "CANCEL" then
--initiate the copy
--CopyFolder is function in the Global Functions area of the project (Alt-D-F)
--[[ You don't want this paragraph?
if CopyFolder(sSourceFolder, sDestFolder) == 0 then
result = Dialog.Message("Folder Copy", "The folder has been successfully copied!", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
else
result = Dialog.Message("Folder Copy", "There was an error copying the folder.", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
end
]]
end
end

tucker
06-15-2005, 07:24 AM
****, I thought that was going to work, it didnt. Any more ideas. I just want the copy folder function to work with no dialog :huh

csd214
06-15-2005, 07:59 AM
Where do you call the global function CopyFolder()?

tucker
06-15-2005, 08:01 AM
In the global functions area...you know (right click on the project and click global functions....you think I have to take some input out of that too?

csd214
06-15-2005, 08:07 AM
The functions in "Global Functions are NOT executed before they are CALLED somwhere in your app:

result = CopyFolder(param1, param2);

(I don't know your function; maybe you don't need the "result = " portion.)

csd214
06-15-2005, 09:10 AM
Sorry, tucker. I was too hasty when I tried to answer your "No one knows?".

Try this:

if sSourceFolder ~= "CANCEL" then
--get the destination folder
sDestFolder = ("C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\IntelApps\\Roxio Easy CD and DVD Creator 6")
--see if the user cancelled
if sDestFolder ~= "CANCEL" then
--initiate the copy
--CopyFolder is function in the Global Functions area of the project (Alt-D-F)
CopyFolder(sSourceFolder, sDestFolder); -- this is the call of the function
end
end

doohoodogg
05-06-2006, 07:49 AM
Man, ive tired of testing and i didnt acomplished anything, i just need this:

On CD_ROOT i have folders w avis in them. Here an example of my CD_ROOT

Autoplay (folder)
autoplay.exe
autoplay.ini
film1 (containing movie.avi & movie.sub)
film2 (the same contents as movie 1 folder)

Now, usualy I use file.copy to copy the contents on my hdd, but i by this way the files are copied (movie.avi & movie.sub) but not the folder so when im finished i find a bunch of .avi and .sub files that i need to manually distribute them in folders created manualy w the movie name (in this case film1, film2).
So what i need is a way to directly copy the folder film1, film2 etc from the CD_ROOT on my selected hdd folder (folder is selected w dialog.browse option).
thx and i hope that someone can help me as im noob, and srry for my bad eng

and heres my script that i usually use, so some1 pls modify it pls for me

result = Dialog.FolderBrowse("Where do u want to copy the folder containig the movie", "C:\\")
StatusDlg.Show();
File.Copy("Hulk2\\Hulk2.avi", result, true, true, true, true, nil);
File.Copy("Hulk2\\Hulk2.sub", result, true, true, true, true, nil);
StatusDlg.Hide();

Oh, and this is fir AMS 6 so stop moving the post in the AMS 5 formu category