any suggestions for how to clean up a mess ?

Frequently I ignore my advice to myself to not persevere when over-tired. Which is why I now find myself with a mess.

When I reformat text to my specification that I’ve copied and pasted into a file it gets bunched up into a single paragraph. Having asked on this forum how to insert a line break after a full stop, I now process all bunched up text with two line spaces - Edit>Project Replace> (dot space) with (dot, line break, line break). Wonderful.

The mess has arisen because, in my weary state, I unwittingly replaced the full stop with a comma. Which would not have been bad enough had I not spotted under Scope that I had not selected ‘Selected Documents Only’.

The upshot is that every full stop in my Project has been replaced by a comma.

Earlier this eek I encounter a glitch with my computer that resulted in my custom settings for almost all of the apps I use having to be redone. Scrivener was amongst them, requiring me to re-enter the license code and redo the back up to Dropbox and so on. As I write this, it occurs to me that I could restore an earlier back-up project file from time Machine, except that I would then have to redo all the copy and paste entries that I’ve done since. And since I don’t think I’ve still got the original text I suspect I could end worse off.

I suppose I could perform a project replace of all the commas in the project, but that would include all the commas that are supposed to be commas. Alternatively I could manually edit each comma to a full stop as I go. But I’m wondering in all this whether there is another way of getting out of the mess I’ve got in?

Did you only have formatting changes? If so, go and check the automatic backups made by Scriv on close (you’ll have been asked to select a save location for these when you set up Scriv initially).

It only keeps so many copies of these, so if you’ve opened and closed the project too many times it may have overwritten all of them with comma’d versions. They’ll be date stamped so go for the most recent pre-comma version.

If you did have text as well as formatting changes, you may find it easier to redo the text than the full stops, but at the very least…
-Go to the most recent pre-comma backup and use that as your base
-In the most recent post-comma project identify any documents in the binder where you’d made text changes, and drag those documents into the backup version of the project.
-For all of these impacted documents (hopefully it’s just a few), decide on a case by case basis whether it’s quicker to manually change all the commas or to retype the text changes using the affected file as reference.
-Once do e, remove whichever versions of the duplicate documents are no longer needed.

Good luck!

OK…

Obviously, if you’ve got suitable backups, you don’t need to read any further… But if you don’t, then here’s a possible way to reduce the manual labour of going through to check every line. It uses regular expressions.

CAUTION: BACKUP what you have and test this on a dummy document. Take snapshots, and use ordinary Find and Replace before you try Project Replace. Also, bear in mind that I’m not an expert at this…

I’m assuming first of all that you’re done the project replace to change all your commas back to full stops and that your text looks like this:

I.e. Every full stop marks a new line, but that there may or may not be spaces between the full stop and the end of the line, and that new lines may start with one or more spaces as well. Because you did the search and replace on full stops before, we know that there is only one full stop on a line.

The one thing we know is that in ordinary text, a comma is often followed by a lower case character: not all the time, of course, but enough that just dealing with ‘full stop + lower case letter’ will take a lot of work off you…

So that means we can search for this pattern “. [none or more spaces] newline newline [none or more spaces] [lowercase-letter]” and replace it with “, [one space] [the same lower case letter” to get a single line, with a comma and space replacing the full stop.

The pattern which matches this is

\.\s*\n\n\s*(\p{LL})

which breaks down to:

\. (full stop)

\s* (none or more spaces)

\n\n (two new lines)

\s* (none or more spaces)

(\p{LL}) (the next letter is lower case and we want to remember it)

Your replacement pattern is , $1 , or “comma space [whatever the lower case was in the matching pattern]”.

To test on your test document, cmd-f to bring up the ordinary Find and Replace document and fill it in like so:

[The reason for using cmd-f rather than Project Replace is that you can cmd-z undo after cmd-f and you can’t after project replace. So only use Project Replace when you know this works for you.]

Notice that the Find Option is set to Regular Expression and the Ignore Case box is unticked.

Press ‘Replace all’ and you should find something like this:

Review to see whether all the lines starting with lower case letters have been joined to the previous one, with the comma replacing the full stop and that nothing horrible has happened.

If it doesn’t work, then it’s likely that your text doesn’t quite match the setup I’ve assumed from your description. (e.g if you’ve got more than one full stop on a line) – in that case, there’s more work to do in getting the match exact.

And of course, it only matches comma + space + lower case. You could improve the pattern, for example by adding a match for commas which come before an ending quotation mark then space and lower case, but personally, I’d try the basic one first before getting fancy…

I hope this doesn’t help you (because your backups work instead)!

But if not, it may be of use to you and anyone else looking at regular expressions. Scrivener uses a variant which isn’t quite the same as many of us are used to and I learnt a lot looking up the differences… Plus, I hope any real experts can spot any better ways of doing this!

Good luck and take backups and snapshots first and then test everything…