mardi 8 septembre 2020

Rename specific pattern of multiple files with another specific pattern in R

I am pretty new to R and could use some help in renaming files.

These are the files:

 [1] "MYD11C3.A2003001.006.2015182092934_LST_Day_CMG_subregion.tif"
 [2] "MYD11C3.A2004001.006.2015213013933_LST_Day_CMG_subregion.tif"
 [3] "MYD11C3.A2005001.006.2015243211529_LST_Day_CMG_subregion.tif"
 [4] "MYD11C3.A2006001.006.2015274114332_LST_Day_CMG_subregion.tif"
 [5] "MYD11C3.A2007001.006.2015309201228_LST_Day_CMG_subregion.tif"
 [6] "MYD11C3.A2008001.006.2015338170025_LST_Day_CMG_subregion.tif"
 [7] "MYD11C3.A2009001.006.2016001145426_LST_Day_CMG_subregion.tif"
 [8] "MYD11C3.A2010001.006.2016035025512_LST_Day_CMG_subregion.tif"
 [9] "MYD11C3.A2011001.006.2016053231728_LST_Day_CMG_subregion.tif"
[10] "MYD11C3.A2012001.006.2016106151313_LST_Day_CMG_subregion.tif"
[11] "MYD11C3.A2013001.006.2016189231222_LST_Day_CMG_subregion.tif"
[12] "MYD11C3.A2014001.006.2016198015925_LST_Day_CMG_subregion.tif"
[13] "MYD11C3.A2015001.006.2016223172712_LST_Day_CMG_subregion.tif"
[14] "MYD11C3.A2016001.006.2016242200237_LST_Day_CMG_subregion.tif"
[15] "MYD11C3.A2017001.006.2017032230414_LST_Day_CMG_subregion.tif"
[16] "MYD11C3.A2018001.006.2018032175447_LST_Day_CMG_subregion.tif"
[17] "MYD11C3.A2019001.006.2019035162351_LST_Day_CMG_subregion.tif"

The pattern "A2003"..."A2019" shall be renamed to "A2002"..."A2018".

Thanks!

Aucun commentaire:

Enregistrer un commentaire