list of file paths and copying these files to new directory

Sarah Reichelt sarahr at genesearch.com.au
Thu Dec 4 18:33:13 EST 2003


> OK I assume that the URL list (see middle box on 
> http://www.armbase.com/screenshots.html ) placed in field 1 via put 
> gHierList into field 1 can be controlled by asking what filepaths are 
> in gHierList and copying them to a destination folder.
>
> All the examples I can find (docs and google) refer to single files of 
> known path and destination
> E.G.
> revCopyFile "/Disk/myfile","/Disk/Folder/"
>
> and
>
> put URL "binfile:/Disk/myfile" into URL "binfile:/Disk/Folder/myfile"
>
> What I need is code, that when a button is clicked, will copy (or 
> move) the files listed in field 1 or gHierList (which ever the list is 
> in) from the source directory to a directory of the users choice.
>
> I assume that to chose a destination directory you would use.
> on mouseUp
>   answer folder "Please choose a folder:"
> end mouseUp
Yes, this will give you a path to the chosen destination folder.
What happens next depends on whether you want to copy all your raw.pic 
files in a single destination directory or whether you want to 
re-create their original folder structure in the destination directory.

Assuming the former (& easier), here is what I would do:

answer folder "Please choose a folder:"
put it into destFolder
set the itemDelimiter to "/"
put field "URL list" into theFiles

repeat for each line f in theFiles
	put destFolder & "/" & last item of f into newFile
	revCopyFile f, newFile
end repeat

This is untested, has no error checking and provides no user feedback, 
but it should be enough to get you started. The "repeat for each" loop 
is always the fastest way to loop through any list.

Cheers,
Sarah
sarahr at genesearch.com.au
http://www.troz.net/Rev/



More information about the use-livecode mailing list