Re: [GRASS-user] Renaming many files with one command
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 there's no example for multiple maps. > > There is an addon g.rename.many for that https://grass.osgeo.org/grass72/manuals/addons/g.rename.many.html Markus ___ grass-user mailing list grass-user@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Renaming many files with one command
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 Vincent, This worked here, too. Looking very closely at the command I used before I now see that I missed adding the substitute s to sed. That's why it didn't work; sed didn't know what to do with the patterns. Mea culpa! And I had a second mug of coffee, too. No excuse here. Thanks and best regards, Rich ___ grass-user mailing list grass-user@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Renaming many files with one command
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-colon. Vincent. ___ grass-user mailing list grass-user@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Renaming many files with one command
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.rename rast=$i,`echo $i | sed s/open_h_/blocked_h_/g`;done Rename raster to Rename raster to GRASS 7.3.svn (local):~ > g.list rast blocked_h_aze blocked_h_qsd GRASS 7.3.svn (local):~ > Is there something in the raster names suffixes that could be hurting sed ? could you provide a g.list rast output ? Anyone else may suggest an explanation? 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, 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 and I've used it many times in > the past. However, it did not work here and I do use backticks to evaluate > the string between them prior to handing the results to the preceeding > command. > >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 > > (This all on one command line; split here to fit MUA width.) > >I don't see a syntax error yet it's not working here in grass-7.3.svn. > Same error message as before for each file. > > Thanks, > > Rich > > > ___ > grass-user mailing list > grass-user@lists.osgeo.org > https://lists.osgeo.org/mailman/listinfo/grass-user ___ grass-user mailing list grass-user@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Renaming many files with one command
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 and I've used it many times in the past. However, it did not work here and I do use backticks to evaluate the string between them prior to handing the results to the preceeding command. 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 (This all on one command line; split here to fit MUA width.) I don't see a syntax error yet it's not working here in grass-7.3.svn. Same error message as before for each file. Thanks, Rich ___ grass-user mailing list grass-user@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Renaming many files with one command
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 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. >There needs to be a second argument to g.rename raster=from,to and the $1 > represents only the 'from' portion. There's no 'to' portion available from > g.list. the second member is given by `echo $i | sed s/open_h_/blocked_h_/g` Good luck, Vincent ___ grass-user mailing list grass-user@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Renaming many files with one command
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. Usage: g.rename [raster=from,to] [raster_3d=from,to] [vector=from,to] [label=from,to] [region=from,to] [group=from,to] [--overwrite] [--help] [--verbose] [--quiet] [--ui] Flags: Parameters: raster raster map(s) to be renamed raster_3d 3D raster map(s) to be renamed vector vector map(s) to be renamed label paint label file(s) to be renamed region region definition(s) to be renamed group imagery group(s) to be renamed ERROR: Sorry is not a valid option ERROR: Sorry is not a valid option ERROR: Sorry is not a valid option ERROR: Option must be provided in multiples of 2 You provided 1 item(s): open_h_max, There needs to be a second argument to g.rename raster=from,to and the $1 represents only the 'from' portion. There's no 'to' portion available from g.list. Looked good, though, and I thought it would work. I had not considered this approach at all! Thanks, Rich ___ grass-user mailing list grass-user@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Renaming many files with one command
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 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 don't see a pattern= option for g.rename or g.copy. > > TIA, > > Rich > ___ > grass-user mailing list > grass-user@lists.osgeo.org > https://lists.osgeo.org/mailman/listinfo/grass-user ___ grass-user mailing list grass-user@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] GRASS, ordinal not in range(128)
Hello Markus, the first suggestion solved the problem thank you so much, now it works :) Gracias Vero también a vos!!! Regards, Andrés. 2017-03-17 16:37 GMT-03:00 Markus Neteler: > Hi, > > On Wed, Mar 15, 2017 at 12:59 PM, Andres Solarte > wrote: > ... > > GRASS 7.3.svn (prueba):~ > t.register -i type=raster input=ndvi_andres > > maps=`g.list raster pattern=prueba_andres* separator=comma` > > start="2015-09-07" increment="1 days" > > Reuniendo información del mapa... > > ERROR: ascii,Definir tiempo absoluto válido para mapa <,25,26,ordinal not > >in range(128) > > > two suggestions: > 1. switch on the fly to English in the session, then run the last command > again: > >export LANG=en_US >export LANGUAGE=en_US >export LC_MESSAGES=en_US >t.register ... > > 2. if that also fails, change the debug level with > > g.gisenv set=DEBUG=1 # or 2 or 3 ... > t.register ... > g.gisenv set=DEBUG=0 > > and see if you can find out from the output where it roughly happens. > > best > Markus > ___ grass-user mailing list grass-user@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/grass-user
[GRASS-user] Renaming many files with one command
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 don't see a pattern= option for g.rename or g.copy. TIA, Rich ___ grass-user mailing list grass-user@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/grass-user