# Show me your scripts!

**URL:** <https://community.textexpander.com/t/show-me-your-scripts/123>\
**Category:** TextExpander Talk\
**Tags:** scripting\
**Created:** [March 20, 2025, 9:16am UTC](https://community.textexpander.com/t/show-me-your-scripts/123 "2025-03-20T09:16:10Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![HelmutHauser](https://sea3.discourse-cdn.com/textexpander/user_avatar/community.textexpander.com/helmuthauser/32/150_2.png) [@HelmutHauser](https://community.textexpander.com/u/HelmutHauser)\
**Post date:** [March 20, 2025, 9:16am UTC](https://community.textexpander.com/t/show-me-your-scripts/123/1 "2025-03-20T09:16:10Z")

</div>

I am interested in seeing everyone’s scripts (in any supported language) they use for TextExpander.

---

<div class="post-metadata">

**Author:** ![HelmutHauser](https://sea3.discourse-cdn.com/textexpander/user_avatar/community.textexpander.com/helmuthauser/32/150_2.png) [@HelmutHauser](https://community.textexpander.com/u/HelmutHauser)\
**Post date:** [March 20, 2025, 9:20am UTC](https://community.textexpander.com/t/show-me-your-scripts/123/2 "2025-03-20T09:20:47Z")

</div>

I start! Here is the code formy “next weekday scripts”. I often say in emails let’s meet “next Monday”, “next Tuesday”, etc. and to make it clearer I add the date. I have written a script that is doing that for me.

The shortcuts are : nxmon, nxtue, etc.

Here is one for Monday. You can easily adapt it to different weekdays. Shoutout to Doug Stephen for providing the core function (below in the code).

```auto
# AppleScript for TextExpander
# Helmut Hauser
# http://www.worksmartandberemarkable.com

# For different weekdays you simply have to change the this line
# e.g., set dateOfNextWeekday to getDateOfNextWeekWeekday(Sunday) -- Sunday
set dateOfNextWeekday to getDateOfNextWeekday(Monday) -- Monday

set myWeekDay to weekday of dateOfNextWeekday
set myMonth to month of dateOfNextWeekday
set myDay to day of dateOfNextWeekday
set myYear to year of dateOfNextWeekday

# Here we put the final output together
# if you want a different format, you will have to change this line
# simply combine variables, like myMonth or my Day), with other textpiece like ")" 
# together with &
#set fullOutput to "next " & myWeekDay & " (" & myMonth & " " & myDay & ", " & myYear & ")"
set fullOutput to "" & myWeekDay & " (" & myMonth & " " & myDay & ")"

return fullOutput
# ----------------------------------------
# subroutine from Doug Stephen
# see http://canadian-fury.com/2012/08/31/performing-fixed-point-date-arithmetic-in-textexpander-using-applescript/
# adapted by Helmut Hauser

# eneric script that allows you to get the date information of a specific upcoming weekday
# e.g., to get the date of next Monday
# getDateOfNextWeekday(Monday)
# Note that the scripts caculates the next upcoming weekday 
# If today is Monday, getDateOfNextWeekday(Monday) will return the date for Monday next week
# If today is Monday, getDateOfNextWeekday(Tuesday) will return the date of tomorrow
on getDateOfNextWeekday(nextWeekdayToFind)
	set returnDate to current date
	if returnDate's weekday is nextWeekdayToFind then return (current date) + (7 * days)
	repeat until returnDate's weekday is nextWeekdayToFind
		set returnDate to returnDate + days
	end repeat
	
	return returnDate
end getDateOfNextWeekday
#----------------------------------------

```

---

<div class="post-metadata">

**Author:** ![HelmutHauser](https://sea3.discourse-cdn.com/textexpander/user_avatar/community.textexpander.com/helmuthauser/32/150_2.png) [@HelmutHauser](https://community.textexpander.com/u/HelmutHauser)\
**Post date:** [March 20, 2025, 9:22am UTC](https://community.textexpander.com/t/show-me-your-scripts/123/3 "2025-03-20T09:22:21Z")

</div>

I also have version which returns the date within a track, the corresponding abbreviation are (nxmon, (nxtue, (nxwed, etc.

Here is the code

```auto
# AppleScript for TextExpander
# Helmut Hauser
# http://www.worksmartandberemarkable.com

# For different weekdays you simply have to change the this line
# e.g., set dateOfNextWeekday to getDateOfNextWeekWeekday(Sunday) -- Sunday
set dateOfNextWeekday to getDateOfNextWeekday(Monday) -- Monday

set myWeekDay to weekday of dateOfNextWeekday
set myMonth to month of dateOfNextWeekday
set myDay to day of dateOfNextWeekday
set myYear to year of dateOfNextWeekday

# Here we put the final output together
# if you want a different format, you will have to change this line
# simply combine variables, like myMonth or my Day), with other textpiece like ")" 
# together with &
#set fullOutput to " (" & myMonth & " " & myDay & ", " & myYear & ")"
set fullOutput to " (" & myMonth & " " & myDay & ")"

return fullOutput

# ----------------------------------------
# subroutine from Doug Stephen
# see http://canadian-fury.com/2012/08/31/performing-fixed-point-date-arithmetic-in-textexpander-using-applescript/
# adapted by Helmut Hauser

# eneric script that allows you to get the date information of a specific upcoming weekday
# e.g., to get the date of next Monday
# getDateOfNextWeekday(Monday)
# Note that the scripts caculates the next upcoming weekday 
# If today is Monday, getDateOfNextWeekday(Monday) will return the date for Monday next week
# If today is Monday, getDateOfNextWeekday(Tuesday) will return the date of tomorrow
on getDateOfNextWeekday(nextWeekdayToFind)
	set returnDate to current date
	if returnDate's weekday is nextWeekdayToFind then return (current date) + (7 * days)
	repeat until returnDate's weekday is nextWeekdayToFind
		set returnDate to returnDate + days
	end repeat
	
	return returnDate
end getDateOfNextWeekday
#----------------------------------------

```

---

<div class="post-metadata">

**Author:** ![jason](https://sea3.discourse-cdn.com/textexpander/user_avatar/community.textexpander.com/jason/32/26_2.png) [@jason](https://community.textexpander.com/u/jason)\
**Post date:** [March 21, 2025, 7:28pm UTC](https://community.textexpander.com/t/show-me-your-scripts/123/4 "2025-03-21T19:28:48Z")

</div>

This is great stuff @HelmutHauser! It makes me so happy to see inline comments! 😃

---

<div class="post-metadata">

**Author:** ![josh.centers](https://sea3.discourse-cdn.com/textexpander/user_avatar/community.textexpander.com/josh.centers/32/8_2.png) [@josh.centers](https://community.textexpander.com/u/josh.centers)\
**Post date:** [March 24, 2025, 2:22pm UTC](https://community.textexpander.com/t/show-me-your-scripts/123/5 "2025-03-24T14:22:29Z")

</div>

This is great, @HelmutHauser! I’ve added the first one to our [Community Snippets Public Group](https://snippets.textexpander.com/group/fa796ecbe167aeb836aced0a65e43b94) with the abbreviation `com.nxmon`.

---

<div class="post-metadata">

**Author:** ![acarter](https://sea3.discourse-cdn.com/textexpander/user_avatar/community.textexpander.com/acarter/32/163_2.png) [@acarter](https://community.textexpander.com/u/acarter)\
**Post date:** [March 24, 2025, 3:40pm UTC](https://community.textexpander.com/t/show-me-your-scripts/123/6 "2025-03-24T15:40:31Z")

</div>

Here’s the same code in JavaScript so it works outside of the Mac:

```auto
var targetWeekday = 1; // 0=Sunday, 1=Monday, ..., 6=Saturday
var now = new Date();
var daysAhead = (targetWeekday - now.getDay() + 7) % 7 || 7; // Skip to next week if today matches
var nextDate = new Date(now.setDate(now.getDate() + daysAhead));
var weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var weekday = weekdays[nextDate.getDay()];
var month = months[nextDate.getMonth()];
var day = nextDate.getDate();
weekday + " (" + month + " " + day + ")";

```

---

<div class="post-metadata">

**Author:** ![FillipeNeyl](https://sea3.discourse-cdn.com/textexpander/user_avatar/community.textexpander.com/fillipeneyl/32/362_2.png) [@FillipeNeyl](https://community.textexpander.com/u/FillipeNeyl)\
**Post date:** [May 4, 2025, 5:27am UTC](https://community.textexpander.com/t/show-me-your-scripts/123/7 "2025-05-04T05:27:38Z")

</div>

Snippet that slugify the text in the clipboard.  
Example: “This is one phrase I’d like to slugify” becomes “this-is-one-phrase-id-like-to-slugify”.

```auto
var text = TextExpander.pasteboardText.﻿toLowerCase﻿(﻿)﻿;
text = text.replace(/[àÀáÁâÂãäÄÅåª]+/g, 'a'); // Special Characters #1
text = text.replace(/[èÈéÉêÊëË]+/g, 'e'); // Special Characters #2
text = text.replace(/[ìÌíÍîÎïÏ]+/g, 'i'); // Special Characters #3
text = text.replace(/[òÒóÓôÔõÕöÖº]+/g, 'o'); // Special Characters #4
text = text.replace(/[ùÙúÚûÛüÜ]+/g, 'u'); // Special Characters #5
text = text.replace(/[ýÝÿŸ]+/g, 'y'); // Special Characters #6
text = text.replace(/[ñÑ]+/g, 'n'); // Special Characters #7
text = text.replace(/[çÇ]+/g, 'c'); // Special Characters #8
text = text.replace(/[ß]+/g, 'ss'); // Special Characters #9
text = text.replace(/[Ææ]+/g, 'ae'); // Special Characters #10
text = text.replace(/[Øøœ]+/g, 'oe'); // Special Characters #11
text = text.replace(/[%]+/g, 'pct'); // Special Characters #12
text = text.replace(/\s+/g, '-'); // Replace spaces with -
text = text.replace(/[^\w\-]+/g, ''); // Remove all non-word chars
text = text.replace(/\-\-+/g, '-'); // Replace multiple - with single -
text = text.replace(/^-+/, ''); // Trim - from start of text
text = text.replace(/-+$/, ''); // Trim - from end of text
TextExpander.﻿appendOutput﻿(text)﻿;

```

---

<div class="post-metadata">

**Author:** ![ArthurSissman](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@ArthurSissman](https://community.textexpander.com/u/ArthurSissman)\
**Post date:** [May 11, 2025, 5:40pm UTC](https://community.textexpander.com/t/show-me-your-scripts/123/8 "2025-05-11T17:40:13Z")

</div>

> [@HelmutHauser](#):
>
> ```auto
> # AppleScript for TextExpander
> # Helmut Hauser
> # http://www.worksmartandberemarkable.com
> 
> # For different weekdays you simply have to change the this line
> # e.g., set dateOfNextWeekday to getDateOfNextWeekWeekday(Sunday) -- Sunday
> set dateOfNextWeekday to getDateOfNextWeekday(Monday) -- Monday
> 
> set myWeekDay to weekday of dateOfNextWeekday
> set myMonth to month of dateOfNextWeekday
> set myDay to day of dateOfNextWeekday
> set myYear to year of dateOfNextWeekday
> 
> # Here we put the final output together
> # if you want a different format, you will have to change this line
> # simply combine variables, like myMonth or my Day), with other textpiece like ")" 
> # together with &
> #set fullOutput to "next " & myWeekDay & " (" & myMonth & " " & myDay & ", " & myYear & ")"
> set fullOutput to "" & myWeekDay & " (" & myMonth & " " & myDay & ")"
> 
> return fullOutput
> # ----------------------------------------
> # subroutine from Doug Stephen
> # see http://canadian-fury.com/2012/08/31/performing-fixed-point-date-arithmetic-in-textexpander-using-applescript/
> # adapted by Helmut Hauser
> 
> # eneric script that allows you to get the date information of a specific upcoming weekday
> # e.g., to get the date of next Monday
> # getDateOfNextWeekday(Monday)
> # Note that the scripts caculates the next upcoming weekday 
> # If today is Monday, getDateOfNextWeekday(Monday) will return the date for Monday next week
> # If today is Monday, getDateOfNextWeekday(Tuesday) will return the date of tomorrow
> on getDateOfNextWeekday(nextWeekdayToFind)
> set returnDate to current date
> if returnDate's weekday is nextWeekdayToFind then return (current date) + (7 * days)
> repeat until returnDate's weekday is nextWeekdayToFind
> set returnDate to returnDate + days
> end repeat
> 
> ```

Thanks for sharing your script.  
I don’t see how this script works. I copied the script as above into a snippet box, gave it a name and abbrev. Tried to run it and nothing happened. What am I doing wrong? Thanks for your help.

---

<div class="post-metadata">

**Author:** ![ArthurSissman](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@ArthurSissman](https://community.textexpander.com/u/ArthurSissman)\
**Post date:** [May 11, 2025, 5:47pm UTC](https://community.textexpander.com/t/show-me-your-scripts/123/9 "2025-05-11T17:47:56Z")

</div>

[quote=“acarter, post:6, topic:123”]  
Here’s the same code in JavaScript so it works outside of the Mac:

```auto
var targetWeekday = 1; // 0=Sunday, 1=Monday, ..., 6=Saturday
var now = new Date();
var daysAhead = (targetWeekday - now.getDay() + 7) % 7 || 7; // Skip to next week if today matches
var nextDate = new Date(now.setDate(now.getDate() + daysAhead));
var weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var weekday = weekdays[nextDate.getDay()];
var month = months[nextDate.getMonth()];
var day = nextDate.getDate();
weekday + " (" + month + " " + day + ")";

```

[Here’s the same code in JavaScript so it works outside of the Mac:]  
I am new to this scripting business. Could you describe how to make this work. I have created a snippet “com.nxtmon2” copy/pasting the Java script above and change the “Rich Text” to “java script” - now what am I missing. Thanks for your help.  
Arthur

---

<div class="post-metadata">

**Author:** ![HaniSarji](https://sea3.discourse-cdn.com/textexpander/user_avatar/community.textexpander.com/hanisarji/32/225_2.png) [@HaniSarji](https://community.textexpander.com/u/HaniSarji)\
**Post date:** [May 11, 2025, 8:10pm UTC](https://community.textexpander.com/t/show-me-your-scripts/123/10 "2025-05-11T20:10:00Z")

</div>

> [@josh.centers](#):
>
> This is great, @HelmutHauser! I’ve added the first one to our [Community Snippets Public Group](https://snippets.textexpander.com/group/fa796ecbe167aeb836aced0a65e43b94) with the abbreviation `com.nxmon`.

I propose the following enhancement to the script, which is more flexible because it allows the user to choose the desired day of the week from a popup. So, instead of creating 7 different snippets for each day of the week, we can have just one:

```JavaScript
// 1. Map weekday names to numbers
let dayMap = {
  "Sunday": 0,
  "Monday": 1,
  "Tuesday": 2,
  "Wednesday": 3,
  "Thursday": 4,
  "Friday": 5,
  "Saturday": 6
};

// 2. Prompt the user for the desired weekday
let choice = "%fillpopup:name=Select the weekday you want to find the next date for:default=Monday:Tuesday:Wednesday:Thursday:Friday:Saturday:Sunday%";
let targetWeekday = dayMap[choice];

// 3. Calculate the next occurrence of the selected weekday
let now = new Date();
let daysAhead = (targetWeekday - now.getDay() + 7) % 7 || 7;
let nextDate = new Date(now.getTime() + daysAhead * 24 * 60 * 60 * 1000);

// 4. Format the date
let weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
let months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];

let weekday = weekdays[nextDate.getDay()];
let month = months[nextDate.getMonth()];
let day = nextDate.getDate();
let year = nextDate.getFullYear();

// 5. Output example: "Tuesday (May 14, 2025)"
weekday + " (" + month + " " + day + ", " + year + ")";
%filltop%

```

This script uses the `key: value` format for redefining popups. I also mentioned this format [here](https://community.textexpander.com/t/is-there-a-more-elegant-way-to-use-an-input-field-that-only-needs-part-of-the-selection-to-be-returned/173/3). It’s a super useful approach because it lets you present user-friendly labels in the dropdown while returning clean, machine-friendly values behind the scenes.

---

<div class="post-metadata">

**Author:** ![josh.centers](https://sea3.discourse-cdn.com/textexpander/user_avatar/community.textexpander.com/josh.centers/32/8_2.png) [@josh.centers](https://community.textexpander.com/u/josh.centers)\
**Post date:** [May 12, 2025, 7:42pm UTC](https://community.textexpander.com/t/show-me-your-scripts/123/11 "2025-05-12T19:42:37Z")

</div>

> [@ArthurSissman](#):
>
> I don’t see how this script works. I copied the script as above into a snippet box, gave it a name and abbrev. Tried to run it and nothing happened. What am I doing wrong? Thanks for your help.

Hi Arthur, glad to see you here! Be sure Content Type is set to JavaScript.

 ![Screenshot 2025-05-12 at 2.42.20 PM](https://us1.discourse-cdn.com/textexpander/original/1X/0cb7f3d2dd369ca0060f391d54eb2ef021a8afaf.png)

---

<div class="post-metadata">

**Author:** ![ArthurSissman](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@ArthurSissman](https://community.textexpander.com/u/ArthurSissman)\
**Post date:** [May 13, 2025, 10:21am UTC](https://community.textexpander.com/t/show-me-your-scripts/123/12 "2025-05-13T10:21:51Z")

</div>

All the scripts I copy are in the correct format: java or apple script. Maybe you could clarify what the beginning and ending signal code should be to tell the body what format it is in. Thanks for trying to help.

---

<div class="post-metadata">

**Author:** ![josh.centers](https://sea3.discourse-cdn.com/textexpander/user_avatar/community.textexpander.com/josh.centers/32/8_2.png) [@josh.centers](https://community.textexpander.com/u/josh.centers)\
**Post date:** [May 14, 2025, 2:22pm UTC](https://community.textexpander.com/t/show-me-your-scripts/123/13 "2025-05-14T14:22:46Z")

</div>

Hi Arthur, I added this Snippet to the [Community Snippets Public Group](https://snippets.textexpander.com/group/fa796ecbe167aeb836aced0a65e43b94) and confirmed it works. Search `com.nextdate` to see how it works!

(We are working on a much better way to share Snippets. Stay tuned!)

---

<div class="post-metadata">

**Author:** ![JohnGarrigues](https://avatars.discourse-cdn.com/v4/letter/j/67e7ee/32.png) [@JohnGarrigues](https://community.textexpander.com/u/JohnGarrigues)\
**Post date:** [August 18, 2026, 10:13pm UTC](https://community.textexpander.com/t/show-me-your-scripts/123/14 "2026-08-18T22:13:18Z")

</div>

OMG! This is awesome! @FillipeNeyl where have you been all my coding life? 😀  
I’m not really a dev, just a hobbyist, but I use snake-case a lot for filenames - a slight mod to your kebab-case script makes it work perfectly. Thanks for sharing this.

---

<div class="post-metadata">

**Author:** ![FillipeNeyl](https://sea3.discourse-cdn.com/textexpander/user_avatar/community.textexpander.com/fillipeneyl/32/362_2.png) [@FillipeNeyl](https://community.textexpander.com/u/FillipeNeyl)\
**Post date:** [August 19, 2026, 8:57pm UTC](https://community.textexpander.com/t/show-me-your-scripts/123/15 "2026-08-19T20:57:44Z")

</div>

Hi @JohnGarrigues thanks! Glad I could help. 🙂
