copy move folder code

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
reelstuff
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 254
Joined: Mon Apr 16, 2007 12:06 am
Contact:

copy move folder code

Post by reelstuff » Thu Mar 12, 2009 8:11 pm

I have been working with some code, that works well for files.

But not for folders.

Code: Select all

on mouseUp
   put the filename of this stack into fPath
   set the itemDelimiter to "/"
   put empty into the last item of fPath
   put "WP_dist" into myVar
   put (fPath &myVar) into myFolderPath
--looking at result to see if path is correct
    put myFolderPath into fld "testing"
   get $folderPath_wpconfig
   put "/WP_dist" after it
   put it into myFolder
-- checking path
   put myFolder into fld testing2
-- I am sure this is where I am going wrong, tried folder, but nothing
--occurs, binfile and file product an empty document with correct title. 
   put url ("binfile:" & myFolderPath) into url ("binfile:" & myFolder) 
end mouseUp
I can see that the binfile designation does not work, but I was just experimenting on a process that might lead me, (the blind man) to
a solution,

any suggestions are always appreciated,

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Thu Mar 12, 2009 8:45 pm

Dear reelstuff,

To copy the file of one folder into another, you need to copy every file individually.

Code: Select all

on mouseUp
   set the itemDel to slash
   put (item 1 to -2 of the effective filename of this stack) & slash & "WP_dist/" into myFolderPath
   put myFolderPath into fld "testing"
   put $folderPath_wpconfig & "/WP_dist/" into myFolder
   set the directory to myFolderPath
   put the files into myFileList
   repeat for each line myFile in myFileList
      put url ("binfile:" & myFolderPath & myFile) into url ("binfile:" & myFolder & myFile)
   end repeat
end mouseUp
If you are copying nested folder, you will need to repeat this script recursively for every folder inside the folder you are copying.

You might also use the revCopyFolder command, but this has advantages as well as disadvantages. A shell function might be an alternative.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

reelstuff
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 254
Joined: Mon Apr 16, 2007 12:06 am
Contact:

Thanks Mark

Post by reelstuff » Fri Mar 13, 2009 1:23 am

Yes, that is what I was thinking would need to be done.

I wish It were as simple as ctrl c and ctrl v

I certainly appreciate your answer,)


One of the things on my wish list is a far more friendly file and folder UI

but we will get there further along...

thanks again for the solution. '

Tim

Post Reply