1

I've been using inkscape to compare a picture against a drawing in another editor. I do this by taking a screenshot of the editor and overlay that over the original image in inkscape. Going back and forth iterating the design. Taking a new screenshot at each step.

I found the best way to do this is to change the linked file path in inkscape. This got me wondering if it's possible to automate this, so that the path gets changed to the latest file in the folder?

EDIT#1 I dont have a way to just overwrite the old screenshot. I'm using dropboxs build in tool and there is no option to do that. I dont really want to install anything else just to do this, so alternative screengrabers are out. And doing it by hand renders the point moot.

  • 1
    Wouldn't it be easier to overwrite the screenshot image file each time? Then the image will update automatically in Inskcape. – Billy Kerr Dec 23 '17 at 12:24
  • I would write a script that updated a symlink to point to the latest file. – chicks Dec 26 '17 at 21:31
  • @chicks that's what I'm looking for. I lack the knowledge to do that though. – Michkov Jan 1 '18 at 9:59
1

Here is my script:

$ cat link_latest.sh 
#!/bin/bash

# TODO: probably good to cd to right directory first

LINK_NAME=latest_link.png # arbitrary
LATEST=$(ls -t | head -1) # https://stackoverflow.com/questions/5885934/bash-function-to-find-newest-file-matching-pattern

rm $LINK_NAME
ln -s $LATEST $LINK_NAME 

As mentioned in the TODO you should make sure you are in the right directory before starting.

Here it is in action:

$ ls *.png *.svg | wc
     69      69    2028
$ touch A68-Arrow-Gray-Right.svg 
$ ./link_latest.sh 
$ ls -l latest_link.png 
lrwxrwxrwx 1 chicks chicks 24 Jan  1 06:50 latest_link.png -> A68-Arrow-Gray-Right.svg
$ touch A19-CircleArrow.png 
$ ./link_latest.sh 
$ ls -l latest_link.png 
lrwxrwxrwx 1 chicks chicks 19 Jan  1 06:50 latest_link.png -> A19-CircleArrow.png

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.