public static String getPath(String s) {
        if (s.startsWith("~/")) s = System.getProperty("user.home") + "/" + s.substring(2);
        else if (s.startsWith("~\\")) s = System.getProperty("user.home") + "\\" + s.substring(2);
        Matcher m = Pattern.compile("\\$\\$|\\$\\{([^\\}]*)\\}").matcher(s);
        StringBuffer result = new StringBuffer();
        while (m.find()) {
            if (m.group().equals("$$")) m.appendReplacement(result, Matcher.quoteReplacement("$"));
            else m.appendReplacement(result, Matcher.quoteReplacement(System.getProperty(m.group(1))));
        }
        m.appendTail(result);
        return result.toString();
    }