Nautilus - Find and replace text - operations on numbers
Use cases
I'm using Ubuntu 18.04.2, Nautilus 3.26.4
Trying to rename a selected group of files that contain a number in the file name, e.g.:
Rename:
"Scanned 2019-06-10 18-40 (10) ok.jpg"
"Scanned 2019-06-10 18-40 (11) acceptable.jpg"
...
"Scanned 2019-06-10 18-40 (23) good.jpg"
"Scanned 2019-06-10 18-40 (24) ok.jpg"
TO:
"Scanned 2019-06-10 18-40 (11) ok.jpg"
"Scanned 2019-06-10 18-40 (12) acceptable.jpg"
...
"Scanned 2019-06-10 18-40 (24) good.jpg"
"Scanned 2019-06-10 18-40 (25) ok.jpg"
Desired behavior
Introducing an additional syntax for "Find and replace text", in Nautilus - the @
wildcard:
For example:
Existing text: "Scanned 2019-06-10 18-40 (@
)"
Replace with: "Scanned 2019-06-10 18-40 ([i+1]
)"
Where:
@
can be used in the Existing text
as a number wildcard
i
can be used in the Replace with
and represents what @
represents for each filename
i
can be accessed only in an arithmetic expression; an arithmetic expression is delimited by a [...]
construct
only the first @
encountered in the Existing text
term should be considered a wildcard (its content will be denoted by the variable i
, that can be used in an arithmetic expression)
Benefits of the solution
This syntax could be useful for example for renaming a large number of scanned pages at once (for example ".jpg" files scanned with a scanner device) (an inexact replace - meaning that the search term
varies because for each filename it contains a different number)
Possible drawbacks
In order to keep it simple, only one @
wildcard and the variable i
(that represents what @
represents for each filename) can be used
Also, because @
could be either a wildcard or a plain character, when it is a plain character it has to be escaped with \
(\@), and because \
could be either an escape character or a plain character - when it is a plain character it has to be escaped with \
(\\).