source folder to script

Hi there I need an apple script that will allow me to select a source folder and then take selection and run a termianl command on it.

At the moment I have


set sourcefolder to (choose folder with prompt "Please choose a source folder" without multiple selections allowed and invisibles)

set command to "find sourcefolder"

now that is not right, but I can’t figure out what I need to put into the first bit of the script to allow me to use it in the second bit.

Any ideas?

set sourcefolder to (choose folder with prompt "Please choose a source folder" without multiple selections allowed and invisibles)
set qsourcefolder to quoted form of (POSIX path of sourcefolder)
set thecommand to "find " & qsourcefolder
do shell script thecommand

Hi there. Thanks for the reply.

Maybe I should have put the other bit in as well.

The find comman needs to perform an action on the source folder.

so I would be doing

do shell script "find sourcefolder -iname specific filename"

I assume this should let me do it, but I can’t quite figure out how to get the sourcefolder selection to be inserted into the terminal command.

at sum point I may want to be able to edit what the specific file name is but for the moment just hard encoding it is fine.

I really wish I knew more about this stuff. It’s just so dam powerful and I always have to hack little bits together to get results.

Hi,

something like this


set sourcefolder to (choose folder with prompt "Please choose a source folder")
set searchTerm to text returned of (display dialog "enter file name" default answer "")
set qsourcefolder to quoted form of (POSIX path of sourcefolder)
set thecommand to "find " & qsourcefolder & " -iname " & quoted form of searchTerm
do shell script thecommand

@chris: without multiple selections allowed and without invisibles is the default parameter of choose folder

I thought so. But I did not bother to confirm it. I just copied the script above me and edited it.

Thanks all

That helped a lot. my script now does what I want and I understand a bit more about manualy inputting data into a running apple script.