• Login
Community
  • Login

mass edit and preserve timestamp?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
preserveedittimestamp
4 Posts 2 Posters 1.3k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O
    Offerel
    last edited by Feb 2, 2019, 8:37 PM

    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?

    M 1 Reply Last reply Feb 2, 2019, 8:57 PM Reply Quote 0
    • M
      Meta Chuh moderator @Offerel
      last edited by Feb 2, 2019, 8:57 PM

      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.

      1 Reply Last reply Reply Quote 2
      • O
        Offerel
        last edited by Feb 2, 2019, 9:08 PM

        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 edit.sh with the following content:

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

        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.

        M 1 Reply Last reply Feb 2, 2019, 9:40 PM Reply Quote 3
        • M
          Meta Chuh moderator @Offerel
          last edited by Meta Chuh Feb 2, 2019, 9:48 PM Feb 2, 2019, 9:40 PM

          @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.

          1 Reply Last reply Reply Quote 2
          1 out of 4
          • First post
            1/4
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors