Tool to copy just timestamp metadata

Tool to copy just timestamp metadata

Recursive copy of file timestampsa

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
cat <<EOF | sudo tee /usr/local/bin/copy-file-timestamps
#!/usr/bin/env python3

import os
import sys
import shutil
from pathlib import Path

def main():
    if len(sys.argv) != 3:
        print("Usage: copy-file-timestamps <source_folder> <destination_folder>")
        sys.exit(1)

    source_folder, destination_folder = sys.argv[1], sys.argv[2]

    file_count = 0  # Initialize the counter

    for root, dirs, files in os.walk(source_folder):
        for name in files + dirs:  # Process both files and directories
            source_file_path = Path(root, name)
            relative_path = source_file_path.relative_to(source_folder)
            destination_file_path = Path(destination_folder, relative_path)

            if destination_file_path.exists():
                shutil.copystat(source_file_path, destination_file_path)
                file_count += 1
                print(f"Timestamps copied from {source_file_path} to folder {destination_folder}")

    print() 
    print(f"Total files and directories with updated timestamps: {file_count}")  # Print the total count
    print()

if __name__ == "__main__":
    main()
EOF

sudo chmod +x /usr/local/bin/copy-file-timestamps

File timestamps in Git

Git doesn’t track timestamps, ali postoje There are some helpful addons to simulate that functionality.

Jedan od uobičajenih načina kod ovih skripti je da za for each file, you could find its last commit date and apply it to the file. An example script is given at: http://stackoverflow.com/questions/2179722/checking-out-old-file-with-original-create-modified-timestamps

Is there an easy way to have Git track timestamps? : git

apt install git-restore-mtime from MestreLion/git-tools: Assorted git tools, including git-restore-mtime

ili tst2005/git-timesync: [####-] Sync timestamps of the local files from the git repository one ili przemoc/metastore: Store and restore metadata from a filesystem.


date 27. Dec 2023 | modified 13. May 2024
filename: Workflow » Second Brain » File Timestamp Problem