SydroCmd Befehle: Unterschied zwischen den Versionen
| Zeile 106: | Zeile 106: | ||
;Example2 | ;Example2 | ||
:with date information | :with date information | ||
:<code>SydroCmd -replace d:\temp\abc.txt | :<code>SydroCmd -replace d:\temp\abc.txt DATE 201612050000 d:\temp\abcnew.txt</code> | ||
:In this example the first argument is <code> | :In this example the first argument is <code>DATE</code> indicating that date information is used. If this string is found it will be replaced by the date given in the next argument (here <code>5/12/2016 00:00</code>). In the <code>abc.txt</code> the variable to be replaced must be given as follows: <code>{DATE|yyyy|+1,y}</code>. This means the result will be ‘2017’, one year added to 2016. | ||
==Zip== | ==Zip== | ||
Version vom 22. Juli 2019, 08:15 Uhr
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.txtwhich 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 = DATEValid Formatstring= possible isyyy,MM,dd,mmValid Number=0, +2, -5or 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 numberto the date)
- Example:
{DATE|dd|+1,d}with a date 30/12/2017 results in 31
- 3. Argument
- ordinary string or in combination with
DATEa date in the formatyyyyMMDDhhmmor 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
DATEindicating 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.txtthe 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.zipwith the pattern*.txttod:\ SydroCmd -unzip d:\ d:\temp\myfile.zip -pattern *.txt
- Example 2
- Unzips a selection of files from
d:\temp\andmyzipfiletod:\ 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\andmyzipfiletod:\ SydroCmd -unzip d:\ d:\temp\myzipfile.zip -pattern *.*