This example is from https://stackoverflow.com/questions/52640820/how-to-rename-files-in-bash-to-increase-number-in-name. The user wants to bump up a numeric fragment of each file's name, for example to rename Cyprinus_carpio_600_nanopore_trim_reads.fasta to Cyprinus_carpio_700_nanopore_trim_reads.fasta.
The names all have the same general pattern *_*_*_* where the third floater is the numeric fragment. rene *_*_*_* *_*_?_* B/100
rene's bump rule B/100 increases each numeric fragment by 100, except that is not exactly what happens in this case because some of the new names already exist. rene's collision avoidance anticipates collisions with new names that have been computed but not yet assigned but it doesn't anticipate new names that would pre-clear collisions. The simple solution is to apply half the bump in two successive commands. rene *_*_*_* *_*_?_* B/50
would rename Cyprinus_carpio_600 to Cyprinus_carpio_650 and Cyprinus_carpio_700 to Cyprinus_carpio_750, clearing the path for a second identical invocation to bump these up to 700 and 800.
The bump rule can also bump down and can be applied to alphabetic fragments.
Last edit: David McCracken 2019-02-24
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This example is from https://stackoverflow.com/questions/52640820/how-to-rename-files-in-bash-to-increase-number-in-name. The user wants to bump up a numeric fragment of each file's name, for example to rename Cyprinus_carpio_600_nanopore_trim_reads.fasta to Cyprinus_carpio_700_nanopore_trim_reads.fasta.
The names all have the same general pattern
*_*_*_*where the third floater is the numeric fragment.rene *_*_*_* *_*_?_* B/100rene's bump rule B/100 increases each numeric fragment by 100, except that is not exactly what happens in this case because some of the new names already exist. rene's collision avoidance anticipates collisions with new names that have been computed but not yet assigned but it doesn't anticipate new names that would pre-clear collisions. The simple solution is to apply half the bump in two successive commands.
rene *_*_*_* *_*_?_* B/50would rename Cyprinus_carpio_600 to Cyprinus_carpio_650 and Cyprinus_carpio_700 to Cyprinus_carpio_750, clearing the path for a second identical invocation to bump these up to 700 and 800.
The bump rule can also bump down and can be applied to alphabetic fragments.
Last edit: David McCracken 2019-02-24