On 03/19/2021, at 19:32, F. Alfredo Rego <[email protected] 
<mailto:[email protected]>> wrote:
> In the end, MediaMouth's was the simplest, as a one-liner that abstracted 
> Jean’s multi-liner:
>> tell application "Finder" to delete POSIX file 
>> "/Volumes/ExternalVolume/Path/To/File"
> ...
> Footnote to answer Chris:
> ...
> My desired workflow is a work-around for an obvious Automator failing in 
> "Copy Finder Items.
> 
> "Copy Finder Items” watches a folder and, whenever a file is ADDED to the 
> folder (see the red rectangle that I used to highlight this spec), it copies 
> the file to a destination folder (with the option to replace existing items).
> 
> <ps 2021-03-19 at 6.18.47 PM.jpg>
> 
> 
> Unfortunately, "Copy Finder Items” does NOTHING whenever a file is MODIFIED 
> (which is what happens every time that the library gets rebuilt during the 
> compile-link workflow).


Hey Alfredo,

If you're content with doing this manually then you've got your answer, but 
I'll add to the plot anyway:


--------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2021/03/21 00:57
# dMod: 2021/03/21 00:57 
# Appl: Finder, System Events
# Task: Handler to Delete a File or Folder Given an:
#     : Alias, HFS-Path, POSIX-Path, $HOME-Based-POSIX-Path, or POSIX-File
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Finder, @System_Events, @Delete, @File, @Folder
--------------------------------------------------------

set fileRef to "~/Downloads/TEST_FILE.txt"

deleteItem(fileRef)

--------------------------------------------------------
--» HANDLERS
--------------------------------------------------------
# Input: Alias, HFS-Path, POSIX-Path, $HOME-Based-POSIX-Path, or POSIX-File
on deleteItem(fileRef)
    if fileRef starts with "~" or fileRef starts with "/" or fileRef contains 
":" then
        tell application "System Events" to set fileRef to (POSIX path of disk 
item fileRef) as «class furl»
    end if
    tell application "Finder" to delete fileRef
end deleteItem
--------------------------------------------------------

I would just use System Events to delete the item, but it directly deletes – 
and in general I'd rather toss things in the trash for safety.


If you want to pursue an automated solution, here are a couple of references.

https://superuser.com/questions/445907/monitor-a-folder-osx-for-file-changes-then-run-a-bash-script
 
<https://superuser.com/questions/445907/monitor-a-folder-osx-for-file-changes-then-run-a-bash-script>

https://mayeu.me/post/how-to-trigger-any-action-when-a-file-or-folder-changes-on-macos-on-the-cheap/
 
<https://mayeu.me/post/how-to-trigger-any-action-when-a-file-or-folder-changes-on-macos-on-the-cheap/>

https://www.tecmint.com/watchman-monitor-file-changes-in-linux/ 
<https://www.tecmint.com/watchman-monitor-file-changes-in-linux/>


--
Best Regards,
Chris

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" rather than 
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/2B95469B-D9EF-43C0-8AFA-03C92D344D45%40gmail.com.

Reply via email to