Community
    • Login

    mass edit and preserve timestamp?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    preserveedittimestamp
    4 Posts 2 Posters 1.7k Views 1 Watching
    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.
    • OfferelO Offline
      Offerel
      last edited by

      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?

      Meta ChuhM 1 Reply Last reply Reply Quote 0
      • Meta ChuhM Offline
        Meta Chuh moderator @Offerel
        last edited by

        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
        • OfferelO Offline
          Offerel
          last edited by

          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.

          Meta ChuhM 1 Reply Last reply Reply Quote 3
          • Meta ChuhM Offline
            Meta Chuh moderator @Offerel
            last edited by Meta Chuh

            @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

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors