I need to remove all the *.tiff files from a set of folders recursively.
The most obvious solution
rm -Rf *.tiff
don't work.
:)
This is the solution I find:
find . -name '*.tiff' -exec rm {} \;
mercoledì 18 giugno 2014
giovedì 12 giugno 2014
Using GDAL to add a field to a shapefile and populate it
The need is:
I have a set of shapefile and need to have another copy of them addind a new field and populating it with the filename (without extension it match a code identifier).
The solution was using a shell dos and the ogr2ogr and ogrinfo utility:
This is the code:
I use the gdal batch utility from osgeo4w package.
-----
mkdir destination-folder
for /R D:\temp\temp2\input-folder %%f IN (*.shp) do (
ogr2ogr D:\temp\temp2\destination-folder\zz_%%~nf_output.shp %%f
cd D:\temp\temp2\input-folder
ogrinfo zz_%%~nf_output.shp -sql "ALTER TABLE zz_%%~nf_output ADD COLUMN filename character(128)"
ogrinfo zz_%%~nf_output.shp -dialect SQLITE -sql "UPDATE zz_%%~nf_output SET filename = '%%~nf'"
cd ..
)
------
Just an explain of some details:
In the ogrinfo command: in the alter-table sql command the tablename inside the sql command should be equals to the filename of shapefile called externally.
In the ogrinfo command: in the update sql-command there is the same relation name-table with name shapefile of the alter-table.
I have a set of shapefile and need to have another copy of them addind a new field and populating it with the filename (without extension it match a code identifier).
The solution was using a shell dos and the ogr2ogr and ogrinfo utility:
This is the code:
I use the gdal batch utility from osgeo4w package.
-----
mkdir destination-folder
for /R D:\temp\temp2\input-folder %%f IN (*.shp) do (
ogr2ogr D:\temp\temp2\destination-folder\zz_%%~nf_output.shp %%f
cd D:\temp\temp2\input-folder
ogrinfo zz_%%~nf_output.shp -sql "ALTER TABLE zz_%%~nf_output ADD COLUMN filename character(128)"
ogrinfo zz_%%~nf_output.shp -dialect SQLITE -sql "UPDATE zz_%%~nf_output SET filename = '%%~nf'"
cd ..
)
------
Just an explain of some details:
In the ogrinfo command: in the alter-table sql command the tablename inside the sql command should be equals to the filename of shapefile called externally.
In the ogrinfo command: in the update sql-command there is the same relation name-table with name shapefile of the alter-table.
lunedì 2 giugno 2014
How find a word
I need to find a word "GAIA_VECTORS_LIST_FAST" but I don't know exactly in what file it can be.
So apply this command in a bash :
find ./ -type f -exec grep "GAIA_VECTORS_LIST_FAST" {} \; -print
et voila.
The response is:
list = gaiaGetVectorLayersList( handle, NULL, NULL, GAIA_VECTORS_LIST_FAST );
./src/providers/spatialite/qgsspatialiteconnection.cpp
simple and fast.
So apply this command in a bash :
find ./ -type f -exec grep "GAIA_VECTORS_LIST_FAST" {} \; -print
et voila.
The response is:
list = gaiaGetVectorLayersList( handle, NULL, NULL, GAIA_VECTORS_LIST_FAST );
./src/providers/spatialite/qgsspatialiteconnection.cpp
simple and fast.
Iscriviti a:
Post (Atom)