Page 1 of 1
Save folder and contents
Posted: Sun Apr 06, 2008 4:28 pm
by reelstuff
I have a set of folders that I would like to include in an application as a template of sorts,
I was looking for a way to put those folders and make them part of the application.
I looked at add non stack files and that will save only one file at a time, so that does not work,
I was wondering if there is a way to use a custom property to do this, but I could not see how it could be done,
I tried to put the files into the stacks, but one of my files is encrypted, so when I try that, the code gets corrupted, I also tried to use a custom property, but ran into the same issue on the encrypted file.
So if I wanted to distribute a set of folders called template along with the application, how would I go about storing those folders and files so that when the application is in a standalone I could reference that folder and copy it into a new folder as a template,
Any thoughts or suggestions are always appreciated.
Thanks.
Tim
Posted: Sun Apr 06, 2008 5:09 pm
by BvG
You can't store folders, but you can create new ones with the "create folder" command.
To store files within a stack, it's best to use custom properties. If you use non-ascii files, you need to use "binfile:" instead of "file:" in the url commands you use to load and unload the files.
Untested example:
Code: Select all
on mouseUp
if there is a file "c:/somefile" then
set the file of this stack to url "binfile:c:/somefile"
create folder "c:/aFolder"
put the file of this stack into url "binfile:c:/aFolder/somefile"
end if
end mouseUp
obviously only works on windows, and if there is a file "somefile" on the c drive.
stuff to look up:
url keyword
create folder command
put command
file keyword
binfile keyword
defaultFolder property
answer folder command
answer file command
there is a operator
there is no operator
Posted: Sun Apr 06, 2008 8:59 pm
by Garrett
Or would it be easier to create a compressed file with all the files, and simply include that file along with your program, have your program create the folders, then uncmpress the file and move all the files into their proper locations?
Posted: Sun Apr 06, 2008 11:45 pm
by keyless
Here is some code I got from somewhere that creates a whole path of folders when needed. I can't remember where I got it but I use it a lot. Thank you to whomever wrote it originally.
on makeFoldersIfNecessary pLocalFilePath2
set the itemdel to "/"
put "/" into tPath
REPEAT with x = 2 to the number of items of pLocalFilePath2
put item x of pLocalFilePath2 & "/" after tPath
IF there is not a folder tPath THEN
create folder tPath
END IF
END REPEAT
END makeFoldersIfNecessary
Posted: Wed Apr 09, 2008 12:00 pm
by reelstuff
Garrett wrote:Or would it be easier to create a compressed file with all the files, and simply include that file along with your program, have your program create the folders, then uncmpress the file and move all the files into their proper locations?
That would be an interesting approach, Many of my questions comes from a lack of experience in working across multiple OS systems,
When thinking about this approach I came to my mind that if you could implement this you could conceivably, use the same compressed file to update, available resources into the application, that might be wishful thinking for me, but it seems possible,
Thank you for posting,
Tim
Posted: Wed Apr 09, 2008 12:06 pm
by reelstuff
keyless wrote:Here is some code I got from somewhere that creates a whole path of folders when needed. I can't remember where I got it but I use it a lot. Thank you to whomever wrote it originally.
on makeFoldersIfNecessary pLocalFilePath2
set the itemdel to "/"
put "/" into tPath
REPEAT with x = 2 to the number of items of pLocalFilePath2
put item x of pLocalFilePath2 & "/" after tPath
IF there is not a folder tPath THEN
create folder tPath
END IF
END REPEAT
END makeFoldersIfNecessary
That looks interesting, basically my issues is that I have a number of files located in a folder, files_1
Most of the methods I have looked at in revolution, are contained to using one file at a time, or a series of images in a folder, but you can only reference one file at a time, which is difficult and extraneous to me,
I wish that I could just store a folder with its contents and include that folder and its files into a variable, but so far I have not found a cross platform method of doing this,
(I am still reading the docs which are so much better than they used to be, someone spent a good deal of time working on this and it is appreciated greatly)
I can package up my "template" folder with the exported rev package, using the excellent install gadget, really nice little gem, however I wonder how to refer to those resources once the application has been distributed.
Anyway, I digress, thanks for your post I will study the code and see how I can make it work.
Tim
Posted: Wed Apr 09, 2008 6:01 pm
by keyless
reelstuff wrote:keyless wrote:Here is some code I got from somewhere that creates a whole path of folders when needed. I can't remember where I got it but I use it a lot. Thank you to whomever wrote it originally.
on makeFoldersIfNecessary pLocalFilePath2
set the itemdel to "/"
put "/" into tPath
REPEAT with x = 2 to the number of items of pLocalFilePath2
put item x of pLocalFilePath2 & "/" after tPath
IF there is not a folder tPath THEN
create folder tPath
END IF
END REPEAT
END makeFoldersIfNecessary
That looks interesting, basically my issues is that I have a number of files located in a folder, files_1
Most of the methods I have looked at in revolution, are contained to using one file at a time, or a series of images in a folder, but you can only reference one file at a time, which is difficult and extraneous to me,
I wish that I could just store a folder with its contents and include that folder and its files into a variable, but so far I have not found a cross platform method of doing this,
(I am still reading the docs which are so much better than they used to be, someone spent a good deal of time working on this and it is appreciated greatly)
I can package up my "template" folder with the exported rev package, using the excellent install gadget, really nice little gem, however I wonder how to refer to those resources once the application has been distributed.
Anyway, I digress, thanks for your post I will study the code and see how I can make it work.
Tim
The code I gave just creates folders. For what you want to do, I believe you could store the files you need in a Custom Property and then extract them when needed. In fact I remember seeing some code around for doing just that, storing a whole folder of files as a custom property.
I'll look around for that code when I have time.
Posted: Wed Apr 09, 2008 6:08 pm
by reelstuff
keyless wrote:reelstuff wrote:keyless wrote:Here is some code I got from somewhere that creates a whole path of folders when needed. I can't remember where I got it but I use it a lot. Thank you to whomever wrote it originally.
on makeFoldersIfNecessary pLocalFilePath2
set the itemdel to "/"
put "/" into tPath
REPEAT with x = 2 to the number of items of pLocalFilePath2
put item x of pLocalFilePath2 & "/" after tPath
IF there is not a folder tPath THEN
create folder tPath
END IF
END REPEAT
END makeFoldersIfNecessary
That looks interesting, basically my issues is that I have a number of files located in a folder, files_1
Most of the methods I have looked at in revolution, are contained to using one file at a time, or a series of images in a folder, but you can only reference one file at a time, which is difficult and extraneous to me,
I wish that I could just store a folder with its contents and include that folder and its files into a variable, but so far I have not found a cross platform method of doing this,
(I am still reading the docs which are so much better than they used to be, someone spent a good deal of time working on this and it is appreciated greatly)
I can package up my "template" folder with the exported rev package, using the excellent install gadget, really nice little gem, however I wonder how to refer to those resources once the application has been distributed.
Anyway, I digress, thanks for your post I will study the code and see how I can make it work.
Tim
The code I gave just creates folders. For what you want to do, I believe you could store the files you need in a Custom Property and then extract them when needed. In fact I remember seeing some code around for doing just that, storing a whole folder of files as a custom property.
I'll look around for that code when I have time.
That would be the ticket, thanks for the help, I appreciate it, Tim