Copying a folder and its contents

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
grovecat
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 99
Joined: Thu Aug 04, 2011 10:32 am
Location: Albany, Western Australia

Copying a folder and its contents

Post by grovecat » Tue May 15, 2012 2:06 pm

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

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Copying a folder and its contents

Post by Klaus » Tue May 15, 2012 2:19 pm

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! :D

OK, you could of course script some kind of repeat loop in LicveCode that does the copying 8)


Best

Klaus

FireWorx
Posts: 362
Joined: Wed Sep 07, 2011 9:39 pm

Re: Copying a folder and its contents

Post by FireWorx » Wed May 16, 2012 7:49 am

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

teacherguy
Posts: 379
Joined: Thu Dec 08, 2011 2:43 am

Re: Copying a folder and its contents

Post by teacherguy » Fri Aug 03, 2012 7:03 am

This really helped me out tonight, thanks Fireworx

Post Reply

Return to “iOS Deployment”