Page 1 of 1

copy move folder code

Posted: Thu Mar 12, 2009 8:11 pm
by reelstuff
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,

Posted: Thu Mar 12, 2009 8:45 pm
by Mark
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

Thanks Mark

Posted: Fri Mar 13, 2009 1:23 am
by reelstuff
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