Working with multiple files Select

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
PeterG
Posts: 168
Joined: Sat Jun 29, 2013 7:56 pm

Working with multiple files Select

Post by PeterG » Wed May 24, 2017 11:37 am

Hi all
I want to select multiple files in Windows, a script to be copied to another folder.
How do one change this code to filter on specific files ie: *.pdf and do a multiple
select.

Code: Select all

local tFileToWIP, tFileWIP
answer file "Select a files to work with" with type "Applications|pdf|*"
put it into tFileToWIP


Or is there another way to do this?

Thanks
Peter G

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Working with multiple files Select

Post by Klaus » Wed May 24, 2017 11:55 am

Hi Peter,

add an S to "answer file..." and remove the asterisk, which showed ALL file types!
This does work:

Code: Select all

...
answer files "Select a files to work with" with type "PDF files|pdf|"
...
Best

Klaus

PeterG
Posts: 168
Joined: Sat Jun 29, 2013 7:56 pm

Re: Working with multiple files Select

Post by PeterG » Wed May 24, 2017 12:59 pm

Hi Klaus
Thank you for the help.
I am trying to copy files selected by the user to and existing folder.
"c:\users\peter\documents\psendwip" in Windows.
Traced it and it does show in the variables and no error code but does not copy it.
My code now looks like this:

Code: Select all

on mouseUp
   local tFileFrom, tFileWIP
put specialFolderPath("documents") & "/" & "psendwip" into tFileWIP
answer files "Select files to work with" with type "Applications|pdf|*"
put it into tFileFrom 
revCopyFile tFileFrom, tFileWIP
end mouseUp
I was wondering if you could tell me what I am doing wrong here.

Thanks
Peter G

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Working with multiple files Select

Post by Klaus » Wed May 24, 2017 1:46 pm

Hi Peter,

if in doubt ALWAYS consult the dictionary!
As the name suggests "revCopyFile" will copy ONE file but you are passing a LIST of files, so it will fail here!

Something like this will work:

Code: Select all

on mouseUp
   local tFileFrom, tFileWIP
   put specialFolderPath("documents") & "/" & "psendwip" into tFileWIP
   
   ## Remove the ASTERISK if you only want to show PDF files!
   answer files "Select files to work with" with type "Applications|pdf|"
   put it into tFileFrom 
   
   ## Since tFileFrom can be MORE than one file you need to loop through this variable:
   repeat for each line tFile in tFileFrom
      revCopyFile tFile, tFileWIP
   end repeat
end mouseUp
Best

Klaus

PeterG
Posts: 168
Joined: Sat Jun 29, 2013 7:56 pm

Re: Working with multiple files Select

Post by PeterG » Wed May 24, 2017 2:15 pm

Hi Klaus
Many Thanks :D
Works perfect.
Much appreciated
Peter G

Post Reply