Skip to content

Commit

Permalink
doc Clarify mention about local links
Browse files Browse the repository at this point in the history
  • Loading branch information
pchiorean committed Apr 8, 2022
1 parent 37b50c7 commit 14f7688
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 25 deletions.
15 changes: 8 additions & 7 deletions cleanup/ReplaceLinks.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
/*
Replace links 22.3.23
Replace links 22.4.8
(c) 2020-2022 Paul Chiorean (jpeg@basement.ro)
Replaces document links from a 2-column TSV file named 'links.txt':
New link path | Document links
path/to/img1.psd | img1.*
img2-cmyk.tif | img2_lowres.jpg, img2-rgb.*
New link path | Document links
path/to/img1.psd | img1.*
path/to/img2-cmyk.tif | img2_lowres.jpg, img2-rgb.*
path/to/img3.tif | [img3.tif]
...
1. <New link path>: new link's absolute path, or just its name if it's in the same folder
2. <Document links>: a list of document links that will be relinked if found
(case insensitive; '*' and '?' wildcards accepted)
1. <New link path>: new link's absolute path
2. <Document links>: a list of document links that will be relinked if found (case insensitive;
'*' and '?' wildcards accepted); if the list is empty, the new link's name will be used.
The file can be saved in the current folder, on the desktop, or next to the script.
Blank lines and those prefixed with `#` are ignored. A line ending in `\` continues on the next line.
Expand Down
14 changes: 9 additions & 5 deletions docs/README.html
Original file line number Diff line number Diff line change
Expand Up @@ -456,18 +456,22 @@ <h4 class="mume-header" id="replacelinks"><strong><code>ReplaceLinks</code></str
<td style="text-align:left">img1.*</td>
</tr>
<tr>
<td style="text-align:left"><strong>img2-cmyk.tif</strong></td>
<td style="text-align:left"><strong>path/to/img2-cmyk.tif</strong></td>
<td style="text-align:left">img2_lowres.jpg, img2-rgb.*</td>
</tr>
<tr>
<td style="text-align:left"><strong>path/to/img3.tif</strong></td>
<td style="text-align:left">[img3.tif]</td>
</tr>
<tr>
<td style="text-align:left">&#x2026;</td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<blockquote>
<p><strong>New link path</strong>: new link&#x2019;s absolute path, or just its name if it&#x2019;s in the same folder <br>
<strong>Document links</strong>: a list of document links that will be relinked if found (case insensitive; <code>*</code> and <code>?</code> wildcards accepted)</p>
<p><strong>New link path</strong>: new link&#x2019;s absolute path<br>
<strong>Document links</strong>: a list of document links that will be relinked if found (case insensitive; <code>*</code> and <code>?</code> wildcards accepted); if the list is empty, the new link&#x2019;s name will be used.</p>
</blockquote>
<p>The TSV file can be saved locally (in the active document folder or its parent folder) or as a global default (on the desktop, next to the script or in <code>Indentz</code> root); local files and files starting with <code>_</code> take precedence. You can include another TSV file by inserting <strong><code>@path/to/file.txt</code></strong> in the desired position, or the global default with <strong><code>@default</code></strong>. Blank lines and those prefixed with <code>#</code> are ignored. You can split a very long line into multiple lines with a backslash (<code>\</code>) added at the end of each segment.</p>
<h4 class="mume-header" id="doccleanup-smallf2small"><strong><code>DocCleanup</code></strong> <small>F2</small></h4>
Expand Down Expand Up @@ -900,7 +904,7 @@ <h4 class="mume-header" id="showproperties-smallf1small"><strong><code>ShowPrope
<hr>
<h2 class="mume-header" id="install">Install</h2>

<p>Many scripts from the repository use linked libraries from the <strong><code>lib/</code></strong> folder, so it&#x2019;s preferable to download the latest release, which is statically linked (the scripts are stand-alone).</p>
<p>Many scripts from the repository use linked libraries from the <strong><code>lib/</code></strong> folder; the <a href="https://github.com/pchiorean/Indentz/releases">releases</a> are statically linked (the scripts are stand-alone).</p>
<ol>
<li>Open <strong>Window &#x2023; Utilities &#x2023; Scripts</strong>.</li>
<li>Right-click on folder <strong>User</strong> and select <strong>Reveal in Finder/Explorer</strong>.</li>
Expand All @@ -913,7 +917,7 @@ <h2 class="mume-header" id="license">License</h2>
<p>All scripts are created by me unless otherwise noted.</p>
<p>&#xA9; 2020-2022 Paul Chiorean &lt;jpeg AT basement.ro&gt;.<br>
The code is released under the MIT License (see <a href="LICENSE.txt">LICENSE.txt</a>).</p>
<p>README.md &#x2022; April 1, 2022</p>
<p>README.md &#x2022; April 8, 2022</p>

</div>

Expand Down
19 changes: 10 additions & 9 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,15 @@ The TSV file can be saved locally (in the active document folder or its parent f
#### **`ReplaceLinks`**
Replaces document links using a TSV substitution file named [**`links.txt`**](samples/links.txt):

| New link path | Document links |
| :- | :- |
| **path/to/img1.psd** | img1.* |
| **img2-cmyk.tif** | img2_lowres.jpg, img2-rgb.* |
| ... | |
| New link path | Document links |
| :- | :- |
| **path/to/img1.psd** | img1.* |
| **path/to/img2-cmyk.tif** | img2_lowres.jpg, img2-rgb.* |
| **path/to/img3.tif** | [img3.tif] |
| ... | |

> **New link path**: new link's absolute path, or just its name if it's in the same folder \
> **Document links**: a list of document links that will be relinked if found (case insensitive; `*` and `?` wildcards accepted)
> **New link path**: new link's absolute path\
> **Document links**: a list of document links that will be relinked if found (case insensitive; `*` and `?` wildcards accepted); if the list is empty, the new link's name will be used.
The TSV file can be saved locally (in the active document folder or its parent folder) or as a global default (on the desktop, next to the script or in `Indentz` root); local files and files starting with `_` take precedence. You can include another TSV file by inserting **`@path/to/file.txt`** in the desired position, or the global default with **`@default`**. Blank lines and those prefixed with `#` are ignored. You can split a very long line into multiple lines with a backslash (`\`) added at the end of each segment.

Expand Down Expand Up @@ -367,7 +368,7 @@ Shows properties and methods of a selected object.
---

## Install
Many scripts from the repository use linked libraries from the **`lib/`** folder, so it's preferable to download the latest release, which is statically linked (the scripts are stand-alone).
Many scripts from the repository use linked libraries from the **`lib/`** folder; the [releases](https://github.com/pchiorean/Indentz/releases) are statically linked (the scripts are stand-alone).

1. Open **Window ‣ Utilities ‣ Scripts**.
2. Right-click on folder **User** and select **Reveal in Finder/Explorer**.
Expand All @@ -384,4 +385,4 @@ All scripts are created by me unless otherwise noted.
© 2020-2022 Paul Chiorean \<jpeg AT basement.ro\>.\
The code is released under the MIT License (see [LICENSE.txt](LICENSE.txt)).

README.md • April 1, 2022
README.md • April 8, 2022
8 changes: 4 additions & 4 deletions lib/ReplaceLink.jsxinc
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* Replaces a link or a list of links with a different one. A selection limits the scope.
* @version 22.2.10
* @version 22.4.8
* @author Paul Chiorean <jpeg@basement.ro>
* @license MIT
* @param {(string|string[])} oldLinks - A link name, or an array of link names to be replaced.
* @param {string} newLink - New link name (if same folder), or full link path.
* @param {(string|string[])} oldLinks - A link name, or an array of document links that will be relinked if found.
* @param {string} newLink - New link's absolute path (or just the name if it's in the same 'Links' subfolder).
* @returns {boolean} - Returns `true` if a replacement was made, `false` if not.
* @example
* replaceLink('link1.jpg', 'link1.psd'); // Both links are in the same folder
Expand All @@ -24,7 +24,7 @@ function replaceLink(oldLinks, newLink) {
// Check if newLink is valid
newLink = /\//g.test(newLink) ? newLink : doc.filePath + '/Links/' + newLink;
if (!File(newLink).exists) {
errors.push("Link '" + newLink + "' not found.");
errors.push("Link '" + decodeURI(newLink) + "' not found.");
return false;
}
// Relink
Expand Down

0 comments on commit 14f7688

Please sign in to comment.