mass edit and preserve timestamp?

  • I have handful of markdown files to edit and change in some of them the path to images. I know, i can do this with “Find in files” / Replace function. But i would like to ask if it is possible to preserve the timestamp of the files, because the original timestamp is important for a sync application. Is that possible and how can i do that?

  • welcome to the notepad++ community, @Offerel

    unfortunately notepad++ can not control the file modification time, and i currently know of no existing plugin that can inject data into files, without changing the time stamps.

    one thing you could do, is to use tools like BulkFileChanger to modify your timestamps after your replaces.
    you could also make a batch script to read and save all timestamps within a folder, make your changes, and restore the timestamps afterwards.

    note: BulkFileChanger is limited command line scriptable, but there are probably better file modification command line tools around, if you want to make a batch script for your needs.

  • many thx for that suggestion. In the meantime i have written a short bash script to do the change on server side (Linux).
    I created a file with the following content:

    for files in /media/mount/user/files/Notes/*.md
        touch -r "$files" "dummy_file"
        sed -i 's/.\/media\//.\/.media\//g' "$files"
        touch -r "dummy_file" "$files"

    Maybe its useful for others. What it odes is the following: it gets all *.md file in the above directory and replace “/media/” with “/.media/”. It uses sed for this. the backslash is only to escape the slash. If i find he time and need that function more, i try to find a better solution.

  • @Offerel

    aaaaaaahh, nice idea to use dummy_file as a temporary timestamp reference file. 👍👍👍

    thanks for sharing 👍, i too think that it might come in handy for others.
    there are quite a few linux and mac users around here, including me.