Automatically update copyright years in project sources.
Copywriter --max-depth 3
This will change all of the copyright years to the current year in supported files in the current working directory, as well as three levels of subdirectories.
For each supported file found in the given parent directory, all copyright strings will be searched for four-digit numbers. The last occurrence in each copyright string will be replaced with the new year. This means that ranges and lists should correctly update the latest year only. For example, in 2024 the following copyright string would only update the year 2023.
- © 1994-2009 Sun, 2010-2019 Oracle, 2019-2023 Apache
+ © 1994-2009 Sun, 2010-2019 Oracle, 2019-2024 Apache
The rest of the string will be left unmodified, including names, punctutation, and symbols like ©. This program does not rely on any formats in the copyright string besides a four-digit year appearing somewhere.
.NET projects with the <Project Sdk="Microsoft.NET.Sdk">
(or the .Web
variant for ASP.NET Core) can use the <Copyright>
property.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Copyright>© 2023 $(Authors)</Copyright>
</PropertyGroup>
</Project>
If the current year is 2024, you can use this program to automatically update the property to
<Copyright>© 2024 $(Authors)</Copyright>
.NET projects with the AssemblyInfo.cs
file (such as .NET Framework projects built with an MSBuild-style project, or any .NET SDK-style project built with <GenerateAssemblyInfo>
set to false
) can use the [assembly: AssemblyCopyright]
assembly-level attribute.
using System.Reflection;
[assembly: AssemblyCopyright("© 2023 Ben Hutchison")]
If the current year is 2024, you can use this program to automatically update the attribute to
[assembly: AssemblyCopyright("© 2024 Ben Hutchison")]
- Download
Copywriter.exe
from the latest release.
Copywriter [options] <parentDirectory>
The directory in which to search for .csproj
and AssemblyInfo.cs
files.
Optional. If omitted, it uses the current working directory.
# update files in current working directory
Copywriter
# update files in a specific directory
Copywriter "C:\Users\Ben\Documents\Projects\Copywriter\Copywriter"
Preview the changes that would be made, but don't actually save them.
Copywriter -n
Recursively search for files in at most <N>
levels of subdirectories.
Optional. If omitted, defaults to 0
, which only searches for files in the current working directory, but not in any of its subdirectories.
Copywriter -d 3 "C:\Users\Ben\Documents\Projects"
Set the copyright year to be this custom year, instead of the current year.
Useful if you're preparing a future release on December 31, for example.
Copywriter -y 2024
Specify a directory name that should not be searched for files.
You can pass this multiple times to exclude multiple directories.
Copywriter --exclude-dir "lib" --exclude-dir "vendor" --exclude-dir "thirdparty"
Do not update the copyright text if this string appears within it.
You can pass this multiple times to skip copyright lines that contain any of the excluded strings.
Copywriter --exclude-name "Microsoft"
Only update the copyright text if this string appears within it.
You can pass this multiple times to skip copyright lines that do not contain any of the included strings.
Copywriter --include-name "Ben Hutchison" --include-name "Benjamin Hutchison"