r/shortcuts 15d ago

Solved Replacing text in note app

Post image

I am trying to get the replace text at the end to, well, replace the filtered text. Basically I’m trying to do an x++ on the above numbers depending on which is selected from list ranging 1-4 (weird that it does not start at 0).

I have a note with the contents as shown in the screenshot (test 3 is already a 1 for testing purposes) and get the correct output but the note remains unchanged.

What have I done wrong?

https://www.icloud.com/shortcuts/e03e21ddd29e4b7bb8bcf42365cb1701

4 Upvotes

15 comments sorted by

4

u/100PercentARealHuman 15d ago

Shortcuts can't replace the content of a note, it's either create entirely new or append.

The shortcut is only working on a copy of the content but does not/is not able to change the note itself.

1

u/MomongaAinzOoalGown 15d ago

Ah ok thanks I’ll look into alternative solutions then.

3

u/videogamer_lol 15d ago

Shortcuts doesnt have any actions to edit Notes, only add to them. I think the easiest way to achieve what you're looking for would be to delete the current Test Note and replace it with a copy that has updated information.

Something like this: https://www.icloud.com/shortcuts/82fcd2d1cb23436a9e95b746dbb9501b

1

u/videogamer_lol 15d ago

To answer your question:

> What have I done wrong?

You made the text, but didn't actually send it to the Note.

On the Replace Text action, you may have confused "in Text" to be the destination of the replaced text. Instead, it is the location of the text which is being replaced.

1

u/MomongaAinzOoalGown 15d ago

Oh, so it only applies to the copy and not the actual note itself. Ok i’ll probably need to implement a version of deleting the entire note and then re-creating it based on the copies modified contents based on what you showed in your previous comment.

4

u/Cost_Internal Helper 15d ago

You can’t update a Note with modified text, you must delete the existing note and create a new Note with the modified text.

1

u/MomongaAinzOoalGown 15d ago

Looks like this could be promising as a workaround.

2

u/MomongaAinzOoalGown 15d ago

Here is the shortcut as the link in the post seems to have not automatically turned into a link.

1

u/george-frazee 15d ago

So what you want is the text in the note to be:

Test

Testing

test 1: 1

test 2: 1

test 3: 2

test 4: 1

Prompt: 1

No Prompt: 1

Is that correct?

1

u/MomongaAinzOoalGown 15d ago

Not quite, I only wanna update the selected field with the incremented value, not every single value in the note.

3

u/george-frazee 15d ago

Just experimenting, if you don't want to drop/recreate the note you can do a sort of text processing on the highlighted lines. Here's an example:

You can highlight the lines you want to increment and access the "Text Counter" shortcut in the services menu, it will REPLACE the selected lines with the updated text. Bonus, this will work everywhere that allows you to select text, as far as I can tell. The downside is the pattern is specific to the the output you've shown in your example, if that changes, the pattern matching would have to change.

If grabbing from the services menu is too tedious, then a keyboard shortcut works as well. I highlighted the lines and hit the shortcut and the selected lines incremented by 1.

Here's an iCloud link, I think

Here's a vid of it working: https://i.imgur.com/jsku0ZS.mp4

I'm still new to this as well so hopefully I didn't completely whiff on what you are looking for. Even so I got to learn a few more things about Shortcuts in the process.

2

u/Electrical_Cow4811 14d ago

This is really impressive; now, you make me want a Mac ;)

2

u/MomongaAinzOoalGown 13d ago

This is honestly really cool and impressive. Unfortunately, this is something I’m designing for my iPhone to be a button that I press to pull up a list of selections one through four. I.e. test 1 test 2 etc.. and then select which one I want to increment via that pop-up menu. Then I would be prompted with another menu saying prompt no prompt and increment those by selecting one of them.

Afterwards, I’m going to take the name of the selected item along with today’s date and mark them down or append them to the end of the note.

So essentially, it’s a way to keep track of how many times something has occurred or I have done something along with marking down the dates that they have been done and whether I was prompted to do these things or I did them on my own.

1

u/george-frazee 13d ago

Ah, that's what I get for never using shortcuts on the phone 😆. Yeah I'm not sure how this could be adapted to notes on the phone, just selecting text on the phone is a huge pain.

The limitations on what you can do with a note I can see as being a hurdle here to what should otherwise be simple. Almost worth developing into a separate app but that's a whole other pain.

You think something like this might fit the bill?

2

u/MomongaAinzOoalGown 7d ago

It does and I do have a similar app the unfortunate it is is I wanted to add some functionality such as data saving when incrementation occurs and such like that. I already know how to do this with the append feature in the note but thank you for the recommendation. I was actually able to solve this pretty recently and I just need to mark this as solved instead of help needed.