Looking to have a folder action that recognizes new files in a folder, then emails the file - applescript

In macOS, I want a folder action to trigger when I place a new file in that folder. The action should grab the filename, not including the path, and use that as the subject, and then attach the file to an email message and send it. Ideally, this would happen behind the scenes as I don't need to see the activity.
I created an Automator script that can grab the file, extract the name, create and send the file. But it's a bit of a kludge. Once I set a variable to the filename, I lose the attachment and have to get the finder item again. Also, it's not working as a Folder Action which is what I really need.
The Automator includes these steps:
Get Specified Finder Items
Get Folder Contents
Filter Finder Items -- I'm only interested in specific files
Set Value of Variable
--path
Run Shell Script -- extract only the filename without the extension
--basename "$#" .pdf
Set Value of Variable
--fileName
New Mail Message
--Subject: fileName
At this point I no longer can attach the specified file because Automator has 'lost' it, so I have to start over with the Get Specified Finder Items, Get Folder Contents, Filter Finder Items, Add Attachments to Front Message. Finally, Send Outgoing Messages.
What I want to happen is when I place a certain file into a directory, the Folder Action triggers, it looks at the file, and if it meets the filter criteria it emails the file, using only the filename without the extension as the Subject.

Create an Automator document type that is a folder action, and attach it to the desired folder. Items added to the specified folder will be passed on to the workflow, so you don’t need to use additional actions to get them.
You are already saving the filtered item paths in a variable, you just need to get them back for the Mail action:
Folder Action receives files added to { wherever }
Filter Finder Items
Set Value of Variable { Variable: path }
Run Shell Script
Set Value of Variable { Variable: fileName }
Get Value of Variable { Variable: path } (ignore input)
New Mail Message { Subject: fileName } (passed files are attached)
Automator workflows are designed to work with multiple input items as a batch; dealing with items one at a time would require a script or third party action such as Dispense Items Incrementally.

Related

AppleScript - make new document at location

I'm trying to create a Numbers' document and then export it to pdf, but my main issue is that the document is created in iCloud and I cannot delete it. To make this new document at a custom location, I'm using make new document at, but I can't get the location specifier correct.
I tried to use a path:
set downloads to path to downloads folder
But I get an error, "can't make alias "path" to type location specifier". And if I try this:
set myDocument to make new document at end of downloads
I get another error Can't obtain alias "Users:username:Downloads"
I don't understand how I can simply create my document at a specific location...
You're mixing apples with oranges. The "location" here is merely the front-to-back position among other similar entities, such as documents / windows. You specify the path on disk when you save the document in a later step.

Place directly into folder without adding UUID folder

I am sorry if this has been answered before but all my searching is not coming up with a result.
I would like to place files directly into the target path and it not generate the UUID folder and then place the file in there. I know about the whole same filename could exist that is why I change the filename on the onChange event before uploading
I have tried to modify the handler.php but either I am not editing the correct lines or something else is going on.
After long and tiring, trying to figure this out, hours I have found a work around on this.
If you sent a blank uuid to the script it will not create the folder and will just place the file in the folder that you told the endpoint to put items. Not sure if this is how the script is supposed to work but it works for me.
I do not have to worry about files that are named the same as i have the script also change the file name before it gets upload with pre-prending a unique string to the file name.
callbacks:
{
onSubmit: function(id, name) {
this.setUuid(id, "")
console.log("onSubmit called")
}
}

Creating a rule that moves all incoming mail to deleted items or perm. Delete?

I am trying to create a rule that will move all incoming mail to deleted items or if possible delete them permenately.
Is anything such as this possible...I believe wildcards are not allowed in Outlook 2010.
You can create a rule in Outlook and assign a VBA macro sub to run. The macro sub should be in the following format:
public sub Test(mail as MailItem)
' do whatever you need
end sub
The mail object represents the incoming email message. You can use the Move method to move the message to another folder. The Delete method can be used to delete it. The Delete method moves the item from the containing folder to the Deleted Items folder. If the containing folder is the Deleted Items folder, the Delete method removes the item permanently.

Talend - load context to subjobs

I am trying to create a main job in Talend that would scan a directory for multiple files (f1.csv, f2.xls...)and then run a separate job created for the specific file. I would like to create a context variable that captures the filename and calls the appropriate job. How can I setup the context variable to store the filename of the found file and pass it to the other jobs?
Create a job called child_job. Inside, go to context tab, and create a new context variable called file with the type String. Inside, you can put components that references this context.file variable.
Now, create another job called main_job. Inside it, put a tFileList. Configure the settings in this component with the desired path where you want to find the files. Then, drag the child_job from the left panel (job designs) or put a tRunJob and set it to call the child_job job. Finally, join the tFileList with the iterate link with the child_job, select the child_job, go to Component tab, add a parameter (the file parameter that you created before) and set the value to ((String)globalMap.get("tFileList_1_CURRENT_FILE")) and you are done!
Something like that:

Handling Undo Delete action in namespace extension

I'm trying to process the Ctrl+Z ( Undo Delete ) context menu action in my namespace extension, but I'm having trouble finding a way to do this.
I see in the doc that one needs to implement FM_UNDELETE_PROC, but no details on how to register this callback.
Also tried to set a Shell hook, but no relevant messages arrive there.
Any thoughts?
Also, how would one register a delete operation so the explorer would allow the Undo to take place.
Now it appears if I do this from another location.
Thanks,
David
Windows has per process (prior to Vista) or global file operation stack. If you use API functions like SHFileOperation or IFileOperation interface you can pass FOF_ALLOWUNDO flag BUT this flag is ignored if the source file parameter does not contain fully qualified path and file names. It means if you want use system file operation stack your shell extension objects MUST have SFGAO_FILESYSTEM attribute and you MUST return valid file path and name when IShellFolder.GetDisplayNameOf is called with SHGDN_FORPARSING parameter. Also it is necessary to implement ITransferSource and ITransferDestination interfaces. So if objects don`t not have SFGAO_FILESYSTEM attribute you must use your own implementation of operation stack.
Undo Delete command in background context menu of folder or in Edit menu is system command and it has no any relation to your shell extension. And you should not process the Ctrl+Z manually.

Resources