Browse the docs

Copy a file to a folder

Copies a file into a folder, or into a subfolder named from its date, name or a counter.

Copy path to to

Details #

Like Move or sort a file, but the original stays. The run's file variable keeps pointing at the original.

Parameters #

ParameterTypeRequiredValuesWhat it does
countertextThe name of the counter {counter} uses.
createFoldersany valueMake missing folders. On by default.
destinationtext
intotextThe variable that receives the path of the copy.
keepExtensionany valueAdd the original extension to name. On by default.
nametextA new name for the copy, as a template.
overwritetextWhat to do when the name is taken: rename (the default; name 2.ext), replace or skip.
pathtextThe file. Optional when a file trigger fired.
sourcetext
subfoldertextA folder inside to, as a template.
totextThe folder to copy into.

Every step also accepts label, onFailure, timeout and dryRunSafe.

Examples #

Copy a file to a folder
Do
  1. Copy “notes.txt” to “~/Backups/{now:yyyy-MM}”
Open in Switchboard to try it

Gotchas #

  • Hazel's Sync action (keep a copy up to date) has no equivalent: this is a one-way copy made once.

  • In a dry run it changes nothing and says what it would do.

Names and tokens #

Wherever a name or folder is a template, {{ }} works as everywhere, and these single-brace tokens are filled in by the step itself:

TokenGives
{name}the file name without its extension
{ext}the extension, without the dot
{fullname}the whole file name
{parent}the name of the folder it is in
{added:yyyy-MM-dd}the date the file was added to its folder (Finder's Date Added), in the format after the colon
{created:…} {modified:…} {opened:…}the creation, modification and last-opened dates
{now:…}today
{counter:3}a number that goes up by one each time this step runs, padded to 3 digits

The counter is kept in shared.hazel.counter.<counter>; counter names it (the default is this macro and step), so two steps that share a counter share the numbers. It survives restarts. Write the rest of a name with {{file.name}}, {{file.ext}} and the other file fields when a file trigger fired.

See also #

Move or sort a file, File operation