Jump to content
Server Maintenance This Week. ×

new record in FMP by dropping a file into a folder


This topic is 5770 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

hi

I want to create a new record in my database each time I drop files in folders on my finder desktop

I use the Folder Actions Scripts

I have one folder per client and many different kind of files

When the record is created in FMP, I want to paste the name of the folder and the name of the file in 2 differents fields...

I wrote an applescript and no problem create a new record and to copy and paste the folder name... but I can't find how do the same thing with the file name...

help...

this is my script :P

thanks

-----------------------------------------------------------------------------------------

property dialog_timeout : 30 -- set the amount of time before dialogs auto-answer.

on adding folder items to this_folder after receiving added_items

try

tell application "Finder"

--get the name of the folder

set the folder_name to the name of this_folder

end tell

-- find out how many new items have been placed in the folder

set the item_count to the number of items in the added_items

--create the alert string

set alert_message to ("Folder Modification :" & return & return) as Unicode text

if the item_count is greater than 1 then

set alert_message to alert_message & (the item_count as text) & " Some Files "

else

set alert_message to alert_message & "New file "

end if

set alert_message to alert_message & "in folder " & «data utxt201C» & the folder_name & «data utxt201D» & "."

set the alert_message to (the alert_message & return & "Create new record for this file in database?")

display dialog the alert_message buttons {"Yes", "No"} default button 2 with icon 1 giving up after dialog_timeout

set the user_choice to the button returned of the result

if user_choice is "Yes" then

tell application "FileMaker Pro Advanced"

activate

create new record

set cell "folder" of last record to folder_name

set cell "file" of last record to file_name

end tell

end if

end try

end adding folder items to

Link to comment
Share on other sites

When you drop items on an AppleScript the result is a list, whether there's 1 or several (I don't know whether they've handled 1 automatically in Leopard or not, but I'll have to assume not).

The question for FileMaker is whether you want a new record for each file dropped. I will assume yes.

Your original script did not get the file name at all, possibly because of confusion re: 1 or several. What I did is build a list of the file names.

I also have no idea what this is (though it doesn't seem to matter; perhaps it's a Leopard text object):P

«data utxt201C»


property dialog_timeout : 30 -- set the amount of time before dialogs auto-answer.



on adding folder items to this_folder after receiving added_items

	

	try

		tell application "Finder"

			--get the name of the folder

			set the folder_name to the name of this_folder

			set file_names to {}

			repeat with i in added_items

				set file_name to name of i

				set file_names to file_names & file_name

			end repeat

		end tell

		

		-- find out how many new items have been placed in the folder

		set the item_count to the number of items in the added_items

		

		--create the alert string

		set alert_message to ("Folder Modification:" & return & return) as Unicode text

		if the item_count is greater than 1 then

			set alert_message to alert_message & (the item_count as text) & " New files "

		else

			set alert_message to alert_message & "New file "

		end if

		set alert_message to alert_message & "in folder " & «data utxt201C» & the folder_name & «data utxt201D» & "."

		set the alert_message to (the alert_message & return & "Create new record for this file in database?")

		

		display dialog the alert_message buttons {"Yes", "No"} default button 2 with icon 1 giving up after dialog_timeout

		set the user_choice to the button returned of the result

		

		if user_choice is "Yes" then

			tell application "FileMaker Pro Advanced"

				activate

				repeat with i in file_names

					create new record

					set cell "folder" of last record to folder_name

					set cell "file" of last record to i as Unicode text

				end repeat

			end tell

		end if

	end try

end adding folder items to

Link to comment
Share on other sites

  • Newbies

thanks for your quick answer,

I try this right now

.

.

.

one minute later

.

.

.

whoa...

fantastic that's work fine, thanks a lot

Edited by Guest
Link to comment
Share on other sites

This topic is 5770 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.