I notice in the dictionary that there is a very useful revCopyFolder command, but it is not supported in iOS. Has anyone got a useful bit of code to make it easy to copy a folder and its contents?
Inherent laziness prompts me to ask this ...
Cheers
Don
Copying a folder and its contents
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Copying a folder and its contents
Hi Don,
since there is no "shell" or whatever, you will need to copy the files one after another
manually, I'm afraid, you lazybone!
OK, you could of course script some kind of repeat loop in LicveCode that does the copying
Best
Klaus
since there is no "shell" or whatever, you will need to copy the files one after another
manually, I'm afraid, you lazybone!
OK, you could of course script some kind of repeat loop in LicveCode that does the copying
Best
Klaus
Re: Copying a folder and its contents
Hi Don,
Here is a script that gets a folder named "example index" and its contents from the IOS special folder path engine folder and copies it over to the IOS special folder path documents folder. NOTE: Its a good idea to set the default folder and run the
a quick check to see what the first line returned is regarding files. Some folders have a line of machine code in the first line where as others like I think the library folder don't. See commented out code below ## answer tFileList ## below.
I know it looks complicated but all you have to do is type in the name of your folder on line 4 and execute the handler in the openstack script. If the folder doesn't exist it will copy it over. Make sure included the folder in the copy files area of the standalone settings and you should be good to go.
on BuildOutDocFolder
put specialFolderPath("engine") into tpath
put specialFolderPath("documents") into tpath2
put "Example Index" into tFolderName
set the defaultfolder to tpath & "/" & tFolderName ## Set the default folder to the child folder to list the files
put the files into tFileList
## answer tFileList ## uncomment this 1 line out to test to make sure the default right and check the first line.
put the number lines of tFileList into tLineNum
create folder tpath2 & "/" & tFolderName
repeat with x = 2 to tLineNum ## repeat for the number of lines ( - 1 if the first line holds machine data)
put line x of tFileList into tFileName
put tpath & "/" & tFolderName &"/" & tFileName into OldFilePath ## the engine folder and file path
put tpath2 & "/" & tFolderName & "/" & tFileName into NewFilePath ## the new path to the folder n documents folder
if there is not a file NewFilePath then ## The file doesnt exist where you want it so make the copy
put URL ("binfile:/" & OldFilePath) into URL ("binfile:/" & NewFilePath)
if there is not a file NewFilePath then ## checks to see if the new file got created where you want it else sad msg.
answer "Sorry couldn't build out Documents folder. See Admin."
exit BuildOutDocFolder
end if
end if
end repeat
end BuildOutDocFolder
Here is a script that gets a folder named "example index" and its contents from the IOS special folder path engine folder and copies it over to the IOS special folder path documents folder. NOTE: Its a good idea to set the default folder and run the
a quick check to see what the first line returned is regarding files. Some folders have a line of machine code in the first line where as others like I think the library folder don't. See commented out code below ## answer tFileList ## below.
I know it looks complicated but all you have to do is type in the name of your folder on line 4 and execute the handler in the openstack script. If the folder doesn't exist it will copy it over. Make sure included the folder in the copy files area of the standalone settings and you should be good to go.
on BuildOutDocFolder
put specialFolderPath("engine") into tpath
put specialFolderPath("documents") into tpath2
put "Example Index" into tFolderName
set the defaultfolder to tpath & "/" & tFolderName ## Set the default folder to the child folder to list the files
put the files into tFileList
## answer tFileList ## uncomment this 1 line out to test to make sure the default right and check the first line.
put the number lines of tFileList into tLineNum
create folder tpath2 & "/" & tFolderName
repeat with x = 2 to tLineNum ## repeat for the number of lines ( - 1 if the first line holds machine data)
put line x of tFileList into tFileName
put tpath & "/" & tFolderName &"/" & tFileName into OldFilePath ## the engine folder and file path
put tpath2 & "/" & tFolderName & "/" & tFileName into NewFilePath ## the new path to the folder n documents folder
if there is not a file NewFilePath then ## The file doesnt exist where you want it so make the copy
put URL ("binfile:/" & OldFilePath) into URL ("binfile:/" & NewFilePath)
if there is not a file NewFilePath then ## checks to see if the new file got created where you want it else sad msg.
answer "Sorry couldn't build out Documents folder. See Admin."
exit BuildOutDocFolder
end if
end if
end repeat
end BuildOutDocFolder
-
- Posts: 379
- Joined: Thu Dec 08, 2011 2:43 am
Re: Copying a folder and its contents
This really helped me out tonight, thanks Fireworx