[GRASS-user] Renaming many files with one command

2017-03-18 Thread Rich Shepard
I inadvertently overwrote a set of 25 output maps and want to change their names using g.rename. The manual page shows that g.rename raster=from,to can be applied to map(s), but there's no example for multiple maps. In my situation I want to change the pattern 'open_h_*' to 'blocked_h_*'. I d

Re: [GRASS-user] Renaming many files with one command

2017-03-18 Thread Vincent Bain
Hi Rich, my one-liner 2-cents solution : for i in `g.list type=vector pattern=open_h_*`;do g.rename vect=$i,`echo $i | sed s/open_h_/blocked_h_/g`;done Hope this helps ! Vincent. Le samedi 18 mars 2017 à 07:42 -0700, Rich Shepard a écrit : >I inadvertently overwrote a set of 25 output maps

Re: [GRASS-user] Renaming many files with one command

2017-03-18 Thread Rich Shepard
On Sat, 18 Mar 2017, Vincent Bain wrote: my one-liner 2-cents solution : for i in `g.list type=vector pattern=open_h_*`;do g.rename vect=$i,`echo $i | sed s/open_h_/blocked_h_/g`;done Vincent, It's close, but not complete: Renames data base element files in the user's current mapset. Usa

Re: [GRASS-user] Renaming many files with one command

2017-03-18 Thread Vincent Bain
Le samedi 18 mars 2017 à 09:13 -0700, Rich Shepard a écrit : > On Sat, 18 Mar 2017, Vincent Bain wrote: > > for i in `g.list type=vector pattern=open_h_*`;do g.rename vect=$i,`echo > > $i | sed s/open_h_/blocked_h_/g`;done >It's close, but not complete: Rich, this should work indeed (I just

Re: [GRASS-user] Renaming many files with one command

2017-03-18 Thread Rich Shepard
On Sat, 18 Mar 2017, Vincent Bain wrote: Rich, this should work indeed (I just tested it down here, it works)... at least if you have sed installed on your system. And also carefully mind the reverse quotes(``) that enclose subprocesses. Vincent, Yes, sed is part of all linux distributions

Re: [GRASS-user] Renaming many files with one command

2017-03-18 Thread Vincent Bain
Weird... sorry, I just notice you meant to rename rasters, not vectors. Anyway, here it works as well with rasters GRASS 7.3.svn (local):~ > g.list rast open_h_aze open_h_qsd GRASS 7.3.svn (local):~ > for i in `g.list type=raster pattern=open_h_*`;do g.renam

Re: [GRASS-user] Renaming many files with one command

2017-03-18 Thread Vincent Bain
Le samedi 18 mars 2017 à 10:45 -0700, Rich Shepard a écrit : >Here's the verbatim command: > > for i in `g.list type=raster pattern=open_h_*`; do g.rename rast=$i,`echo > $i | sed /open_h_/blocked_h_/g`; done > Lastly, I would suggest you to try the same command with no space after the semi

Re: [GRASS-user] Renaming many files with one command

2017-03-18 Thread Vincent Bain
Oops sorry to all for my very noisy replies... I just see you omitted the 's' argument to sed ! We've got it ! Bye, Vincent. Le samedi 18 mars 2017 à 10:45 -0700, Rich Shepard a écrit : > On Sat, 18 Mar 2017, Vincent Bain wrote: > > > Rich, this should work indeed (I just tested it down here,

Re: [GRASS-user] Renaming many files with one command

2017-03-18 Thread Rich Shepard
On Sat, 18 Mar 2017, Vincent Bain wrote: Weird... sorry, I just notice you meant to rename rasters, not vectors. Anyway, here it works as well with rasters GRASS 7.3.svn (local):~ > for i in `g.list type=raster pattern=open_h_*`;do g.rename rast=$i,`echo $i | sed s/open_h_/blocked_h_/g`;done

Re: [GRASS-user] Renaming many files with one command

2017-03-18 Thread Markus Neteler
On Mar 18, 2017 10:42 AM, "Rich Shepard" wrote: > > I inadvertently overwrote a set of 25 output maps and want to change their > names using g.rename. The manual page shows that g.rename raster=from,to can > be applied to map(s), but there's no example for multiple maps. There is an addon g.ren

Re: [GRASS-user] Renaming many files with one command

2017-03-18 Thread Markus Neteler
On Mar 18, 2017 7:55 PM, "Markus Neteler" wrote: > > On Mar 18, 2017 10:42 AM, "Rich Shepard" wrote: > > > > I inadvertently overwrote a set of 25 output maps and want to change their > > names using g.rename. The manual page shows that g.rename raster=from,to can > > be applied to map(s), but

Re: [GRASS-user] Renaming many files with one command

2017-03-19 Thread Rich Shepard
On Sun, 19 Mar 2017, Markus Neteler wrote: There is an addon g.rename.many for that. It takes a CSV file if I recall correctly. Markus, Thanks. Rich ___ grass-user mailing list grass-user@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/g