Page 1 of 1
Working with multiple files Select
Posted: Wed May 24, 2017 11:37 am
by PeterG
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
Re: Working with multiple files Select
Posted: Wed May 24, 2017 11:55 am
by Klaus
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
Re: Working with multiple files Select
Posted: Wed May 24, 2017 12:59 pm
by PeterG
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
Re: Working with multiple files Select
Posted: Wed May 24, 2017 1:46 pm
by Klaus
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
Re: Working with multiple files Select
Posted: Wed May 24, 2017 2:15 pm
by PeterG
Hi Klaus
Many Thanks
Works perfect.
Much appreciated
Peter G