Skip to the content.

Timestamp Copy

TimestampCopy.ps1 is PowerShell script that integrates directly into the Windows File Explorer context menu, enabling you to copy and paste file and folder timestamps with ease.

This solution is especially useful when you need to preserve or replicate Date Created and Date Modified values across files or folders – ideal for organizing backups, restoring files, or syncing metadata.

ContextMenu
(Context Menu)

Download

GitHub Release

Usage (Context Menu)

Right-click on a file or folder under the context menu and choose:

Right-click on another file or folder and choose:

Right-click on the same (or any other) file or folder and choose:

Usage (CLI)

The script is made to be run from the context menu, but it can also be run directly from the command line.

Parameters:

-Help (-h)                       Print help.
-Version (-v)                    Print the current version of the script.
-Install (-i)                    Install the context menu entries for the script in Standalone Mode.
-InstallBackgroundMode (-b)      Install the context menu entries for the script in Background Mode (runs without a terminal window).
-Uninstall (-u)                  Uninstall the context menu entries and remove related data.
-Copy (-c) <path>                Copy timestamps of the specified file or folder to the clipboard.
-Paste (-p) <path>               Paste the copied timestamps to the specified file or folder.
-PasteDateCreated (-pc) <path>   Paste only the copied Date Created timestamp to the specified file or folder.
-PasteDateModified (-pm) <path>  Paste only the copied Date Modified timestamp to the specified file or folder.
-Undo (-z)                       Restore the previous timestamps of the last modified file or folder.
-Quiet (-q)                      Suppress output messages. After run check $LastExitCode or $? for exit code.
-SkipConfirm (-y)                Skip confirmation prompts when applying changes.
*none*                           Show the install/uninstall menu.

Some examples:

# Copy timestamps
.\TimestampCopy.ps1 -c "C:\Foo.txt"

# Paste timestamps
.\TimestampCopy.ps1 -p "D:\Bar.txt"

# Paste timestamps without output messages (confirm prompt still shown)
.\TimestampCopy.ps1 -p "D:\Bar.txt" -q

# Paste timestamps without output messages and confirm prompt
.\TimestampCopy.ps1 -p "D:\Bar.txt" -q -y

# Paste Date Created
.\TimestampCopy.ps1 -pc "D:\Bar.txt"

# Paste Date Modified
.\TimestampCopy.ps1 -pm "D:\Bar.txt"

# Undo
.\TimestampCopy.ps1 -z

It can also be run without any argument, which will show the install/uninstall menu:

Timestamp Copy (2.1.0)

[i] Install
[b] Install (Background Mode)
[u] Uninstall
[h] Help

[q] Quit

Choose option:

Requirements

Installation

  1. Clone the repository.
     git clone https://github.com/jurakovic/timestamp-copy.git
    
  2. Open an elevated Powershell terminal (‘Run as Administrator’).
  3. Navigate to the directory where you cloned the repository.
     cd timestamp-copy
    

If already not set, you may need to change the execution policy to allow running scripts.

Set-ExecutionPolicy -Scope CurrentUser Unrestricted

More details about the PowerShell execution policies can be found here and here.

  1. Install the context menu entries.
    Run the script with the -i option
     .\TimestampCopy.ps1 -i
    

    or with the -b option to install it in Background Mode (without a terminal window)

     .\TimestampCopy.ps1 -b
    

If you set different execution policy, you may need to revert it back to the default.

Set-ExecutionPolicy -Scope CurrentUser Restricted

Implementation Details

Operations

The script implements five main operations:

Copy

Paste

Paste "Date Created"

Paste "Date Modified"

Undo

Script Modes

The script can operate in three different modes, and each mode defines slightly different behavior of the script.
The mode is determined by the way the script is executed, and although there is a parameter for that it’s not meant to be set by the user. The default is Terminal and the script will set the desired mode for the context menu integration based on installation user input.

Terminal

Standalone

Background

Clipboard

As a “clipboard” the script uses two files in the %LOCALAPPDATA%\TimestampCopy folder.

File contents are Base64 encoded to avoid manipulation to ensure that the data is stored in a consistent format.
If the contents are not in the expected format, the script will output an error message and exit.

Screenshots

Copy
Copy

Paste
Copy

Limitation

This script is designed to work with only one selected file or folder at a time. While it does appear in the context menu when multiple items are selected, it will be executed independently for each item. This can lead to unexpected behavior. For accurate and predictable results, always use it with a single selection.

Disclaimer

This script is provided as-is, without any warranties or guarantees of fitness for a particular purpose. While it should work reliably in most cases, use it at your own risk.


Old Versions

Release Source Description
1.0.0 1.0.0 Initial tscp.sh written in Bash. It was created solely for educational and experimental use.
2.0.0-preview.1 2.0.0-preview.1 Direct port of the original Bash script into PowerShell, with only the minimal necessary changes made to ensure proper execution in a PowerShell environment.
2.0.0 2.0.0 Complete rewrite of the original Bash script in native PowerShell syntax.

References