Looking for an applescript to move files from a hot folder

I am a scripting Noob.

We output PDF files with the naming convention 123456_layout.pdf.
We want to have these files go into a hot folder which will then move them to a subfolder of a corresponding job folder.
Job folders are named 123456.customer. Subfolders will always be named the same within the customer folder.123456.customer/FLG/MetrixImpose
The hot folder will reside on a mounted server. The hot folder will be on the same volume as the customer job folders.
Hot folder = Maggie/TempJobs/Metrixhotfolder.
Customer job folders = Maggie/Tempjobs/123456.customer

I have searched around and found some similar scripts that seemed like they were close but did not work when I tried them. The file never moved.

If my memory is right, folder actions apply to local folders, not on ones stored on networks.

If I am right, you may use a local hot folder which will move the files where they must be on the network.

Yvan KOENIG running Yosemite 10.10.5 in French (VALLAURIS, France) mercredi 16 septembre 2015 18:00:08

OK. So I create a local hot folder. How do I tell the hot folder to look for folders that begin with corresponding 6 digits on a mounted server.

In the folder “:Library:Scripts:Folder Action Scripts:” you will find several samples.
Here is one of them slightly edited

convert - PostScript to PDF

This Folder Action handler is triggered whenever items are added to the attached folder.
The script convert files from PostScript format to PDF.

Copyright © 2002“2007 Apple Inc.

You may incorporate this Apple sample code into your program(s) without
restriction.  This Apple sample code has been provided "AS IS" and the
responsibility for its operation is yours.  You are not permitted to
redistribute this Apple sample code as "Apple sample code" after having
made changes.  If you're going to redistribute the code, we require
that you make it clear that the code was descended from Apple sample
code, but that you've made changes.

# Slightly edited by Yvan KOENIG (VALLAURIS, Fraznce) 2015/09/16

property done_foldername : "PDF Files"
property originals_foldername : "Original Files"
property newimage_extension : "pdf"
-- the list of file types which will be processed 
-- eg: {"PICT", "JPEG", "TIFF", "GIFf"} 
property type_list : {"EPSF"}
-- since file types are optional in Mac OS X, 
-- check the name extension if there is no file type 
-- NOTE: do not use periods (.) with the items in the name extensions list 
-- eg: {"txt", "text", "jpg", "jpeg"}, NOT: {".txt", ".text", ".jpg", ".jpeg"} 
property extension_list : {"eps", "ps"}

on adding folder items to this_folder after receiving these_items
	# step 1
	# Move the added files in a subfolder so that the system will not assume that a new< file is added if we change a file name
	tell application "Finder"
		if not (exists folder done_foldername of this_folder) then
			make new folder at this_folder with properties {name:done_foldername}
		end if
		set the results_folder to (folder done_foldername of this_folder) as alias
		if not (exists folder originals_foldername of this_folder) then
			make new folder at this_folder with properties {name:originals_foldername}
			set current view of container window of this_folder to list view
		end if
		set the originals_folder to folder originals_foldername of this_folder
	end tell # Finder
		repeat with i from 1 to number of items in these_items
			set this_item to item i of these_items
			set the item_info to the info for this_item
			if (alias of the item_info is false and the file type of the item_info is in the type_list) or (the name extension of the item_info is in the extension_list) then
				tell application "Finder"
					my resolve_conflicts(this_item, originals_folder, "")
					set the new_name to my resolve_conflicts(this_item, results_folder, newimage_extension)
					set the source_file to (move this_item to the originals_folder with replacing) as alias
				end tell # Finder
				process_item(source_file, new_name, results_folder)
			end if
		end repeat
	on error error_message number error_number
		if the error_number is not -128 then
			tell application "SystemUIServer"
				display dialog error_message buttons {"Cancel"} default button 1 giving up after 120
			end tell
		end if
	end try
end adding folder items to

on resolve_conflicts(this_item, target_folder, new_extension)
	-- NOTE that the variable this_item is a file reference in alias format 
	tell application "Finder"
		set the file_name to the name of this_item
		set file_extension to the name extension of this_item
		if the file_extension is "" then
			set the trimmed_name to the file_name
			set the trimmed_name to text 1 thru -((length of file_extension) + 2) of the file_name
		end if
		if the new_extension is "" then
			set target_name to file_name
			set target_extension to file_extension
			set target_extension to new_extension
			set target_name to (the trimmed_name & "." & target_extension) as string
		end if
		if (exists document file target_name of target_folder) then
			set the name_increment to 1
				set the new_name to (the trimmed_name & "." & (name_increment as string) & "." & target_extension) as string
				if not (exists document file new_name of the target_folder) then
					-- rename to conflicting file
					set the name of document file target_name of the target_folder to the new_name
					exit repeat
					set the name_increment to the name_increment + 1
				end if
			end repeat
		end if
	end tell # Finder
	return the target_name
end resolve_conflicts

-- this sub-routine processes files 
on process_item(source_file, new_name, results_folder)
		set the source_item to the quoted form of the POSIX path of the source_file
		-- the target path is the destination folder and the new file name
		set the target_path to the quoted form of the POSIX path of (((results_folder as string) & new_name) as string)
		with timeout of 900 seconds
			do shell script ("pstopdf " & source_item & " -o " & target_path)
		end timeout
	on error error_message
		tell application "SystemUIServer"
			display dialog error_message buttons {"Cancel"} default button 1 giving up after 120
		end tell
	end try
end process_item

It receive the list of newly added files.
At very firs execution it create two folders in which it will move the received files and the edited ones if it must edit files.
Then it build unique names for resulting files so that they don’t replicate one already available in the original_folders.
I guess that this step will be useless for you.
Then, for each added file, it enter the handler named process_item tp do the required task.

With that you have a neat skeleton for your specific script.

Yvan KOENIG running Yosemite 10.10.5 in French (VALLAURIS, France) mercredi 16 septembre 2015 21:36:12