[PLUG] Removing initial characters from all file names in directory

Robert Citek robert.citek at gmail.com
Fri Feb 8 21:18:38 UTC 2019


$ ls -1
BMRR_Pits.cpg
BMRR_Pits.dbf
BMRR_Pits.prj
BMRR_Pits.shp
BMRR_Pits.shx

$ rename 's/^BMRR_//' BMRR_*

$ ls -1
Pits.cpg
Pits.dbf
Pits.prj
Pits.shp
Pits.shx

Regards,
- Robert

On Fri, Feb 8, 2019 at 1:05 PM Rich Shepard <rshepard at appl-ecosys.com>
wrote:

> I have a directory with 30 files. Each filename begins with BMRR_ and I
> want
> to strip that off, leaving the rest of the name unchanged. There are 5
> different extensions on the files.
>
> I've used rename to change file extensions but not characters at the front
> or middle of filenames. My web searches (after a couple of futile efforts
> with sed and rename) found a number of suggestions for removing a string
> within each filename or characters at the end of each file name. I tried
> modifying each suggestion to remove the 5 initial characters but none
> worked.
>
> There are six sets of five files; one set is:
> BMRR_Pits.cpg  BMRR_Pits.dbf  BMRR_Pits.prj  BMRR_Pits.shp  BMRR_Pits.shx
>
> Suggestions needed.
>
> TIA,
>
> Rich
> _______________________________________________
> PLUG mailing list
> PLUG at pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug
>



More information about the PLUG mailing list