Jump to content

Modifying files using Shortcut doesn't seem to work [Fixed 5.0 b2050]


gordon192
 Share

Recommended Posts

I have a Shortcut that sets the creation and modification date of a file to an arbitrary value. If I use a File Action and connect it to Alfred 5's "Run Shortcut" action, it doesn't work. It appears to work and runs without error, but the original file is never modified.

 

However, if instead of using Run Shortcut, I use a Run Script action and execute the following AppleScript, it works perfectly:

 

on run argv
	set theQuery to item 1 of argv
	set filePath to POSIX file theQuery
	tell application "Shortcuts Events" to run shortcut "Set Creation and Modification Date" with input filePath
end run

 

The Shortcut: https://www.icloud.com/shortcuts/fa16fc79010246d39e5012d2ea19c2a5

 

I think I have an idea of what might be happening. If I use the "shortcuts" command line utility to run a shortcut and pass it a file, it appears that shortcuts doesn't actually act on the original file. Instead, it creates a copy of the file in a temporary directory and acts on that instead. This means that any action that attempts to modify the original file just ends up modifying the copy. By contrast, if I run a shortcut using "Shortcut Events" from AppleScript and pass it a file, it operates directly on the original file.

 

I'm not sure what Alfred is doing internally, but the behavior I'm seeing makes me suspect that when you pass a file to Alfred, Shortcuts is executing against a copy of the file and not the original, which will break many workflows.

alfred_shortcuts.png

Link to comment
Share on other sites

  • Andrew changed the title to Modifying files using Shortcut doesn't seem to work [Fixed 5.0 b2050]

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
 Share

×
×
  • Create New...