[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Editing Problem with bash script and sed

On Tue 14 Nov 2017 at 11:07:47 (-0500), Thomas George wrote:

> The problem is editing long file names to shorten them.
> An example group of file names is attached.

I thought someone might mention MC for doing this.

The sequence of operations I would use here is:

Select the files you want to change. Usually it's sufficient to
select all the files in the directory because any stragglers that
don't match won't get changed.

Leave the cursor on any one of the files.

Press F6 (rename).

In the "to:" field, type *

With the mouse, drag across the text you want to eliminate.

In the "Move <N> files with source mask:" field, paste the
selected text and add * at the end.

It will now look something like:

Move <N> files with source mask:
St. John's College Choir, Cambridge - [19*


Press Return and the matching files will have that string

Repeat, pasting:
88  421 022-2 10DC] Christmas Weekend (16 Fav*

ourite Carols) - *

With such a long initial string, you will probably not be able
to see all of it at the bottom of the screen so I've demonstrated
how to do it in parts. Of course, you can Copy the entire initial
string from a normal ls command's output.

I leave the digits at the start of the carols' names so that
they play in the expected order when globbed.

MC can of course do more flexible selection of and changes to
filenames than just this simple case.

One minor point: I find it safer and more reliable to use MC
with --nomouse so that the mouse can be used for selecting and
pasting text (without shift), but not for pressing buttons etc.


Reply to: