SydroCmd Befehle
Version vom 22. Juli 2019, 08:58 Uhr von Christina (Diskussion | Beiträge)
Extract
Extracts strings from each line within an ASCII file.
Argument | Description |
---|---|
1 | -extract
|
2 | sourcefile |
3 | -string or -pos or -split ( -string =search for a string, -pos =select a position, -split =delimits the string)
|
4 | either string or position as a number |
5 | -endstring or -endlen or -array
|
6 | either a string or the work blank or a position as integer, depending on the previous argument. With -split a comma-separated list of indices is required indicating which items should be saved
|
7 | targetfile |
- Example1
- extracts a string from each line within
d:\temp\abc.txt
which follows directly afterval=
and ends at the next blank. SydroCmd -extract d:\temp\abc.txt -string :val= -endstring blank d:\temp\extract.txt
- Example 2
- extracts a string from each line within d:\temp\abc.txt starting from position 15 with a length of 25 characters.
SydroCmd -extract d:\temp\abc.txt -pos 15 -endlen 25 d:\temp\extract.txt
Download
Downloads a file with a valid URL to the local memory.
Argument | Description |
---|---|
1 | -download
|
2 | URL (possibly with spaceholders like {0}
|
3 | Arguments separated by a comma filling the spaceholders in the URL |
4 | targetfile |
- Example
- Downloads a file from the NOAA data archive. Variables are the year, month, day.
SydroCmd -download http://nomads.ncdc.noaa.gov/modeldata/cfsv2_forecast_mm_9mon/{0}/{0}{1}/{0}{1}{2}/{0}{1}{2}00/flxf.01.{0}{1}{2}00.{3}{4}.avrg.grib.grb2 2016,12,02,2016,12 D:\temp\tmp.grb2
Replace
Replaces all strings with a new string within a file. Is able to handle current date information.
Argument | Description |
---|---|
1 | -replace
|
2 | sourcefile |
3 | string to be searched for (see options) |
4 | Replacement string, string to be inserted (see options) |
5 | targetfile (if not given, sourcefile will be overwritten) |
Options
- 2. Argument
- String to be searched for that will be replaced
- Format=
[KEYWORD|Valid Formatstring|Valid Number,DateInterval}
KEYWORD = DATE
Valid Formatstring
= possible isyyy
,MM
,dd
,mm
Valid Number
=0, +2, -5
or any other integer (adds/subtracts the number of years, months, days, hours, minutes as given with the number)DateIntervall
=y, M, d, h, m
(is used to add thevalid number
to the date)
- Example:
{DATE|dd|+1,d}
with a date 30/12/2017 results in 31
- 3. Argument
- ordinary string or in combination with
DATE
a date in the formatyyyyMMDDhhmm
or the keywordNow
Examples
- Example1
- simple with “hallo” replaced by “goodbye”. The sourcefile will be overwritten.
SydroCmd -replace d:\temp\abc.txt hallo goodbye
- Example2
- with date information
SydroCmd -replace d:\temp\abc.txt DATE 201612050000 d:\temp\abcnew.txt
- In this example the first argument is
DATE
indicating that date information is used. If this string is found it will be replaced by the date given in the next argument (here5/12/2016 00:00
). In theabc.txt
the variable to be replaced must be given as follows:{DATE|yyyy|+1,y}
. This means the result will be ‘2017’, one year added to 2016.
Zip
Zips files into a Zip File Format.
Argument | Description |
---|---|
1 | -zip
|
2 | source directory |
3 | zipfilename |
4 | -pattern or -list
|
5 | the pattern or a comma-separated list |
- Example 1
- Compresses all files in directory
d:\temp\
with*.txt
-extension to filemyfile.zip
SydroCmd -zip d:\temp\ myfile.zip -pattern *.txt
- Example 2
- Compresses a list of files in directory
d:\temp\
with*.txt
-extension to filemyfile.zip
SydroCmd -zip d:\temp\ myzipfile.zip -list d:\mylist\file1.txt "d:\many files\newfile.doc"
UnZip
UnZips files from a Zip File.
Argument | Description |
---|---|
1 | -unzip
|
2 | source directory |
3 | source zipfilename |
4 | -pattern or -list
|
5 | the pattern or a comma-separated list |
- Example 1
- Unzips all files in directory
d:\temp\
and zipfilemyfile.zip
with the pattern*.txt
tod:\
SydroCmd -unzip d:\ d:\temp\myfile.zip -pattern *.txt
- Example 2
- Unzips a selection of files from
d:\temp\
andmyzipfile
tod:\
SydroCmd -unzip d:\ d:\temp\myzipfile.zip -list d:\mylist\file1.txt "d:\any directory\newfile.doc"
- Expamle 3
- Unzips all files in the zipfile from
d:\temp\
andmyzipfile
tod:\
SydroCmd -unzip d:\ d:\temp\myzipfile.zip -pattern *.*