A tool for scan and replace file content
Instead of global search and replace, it can specify replace scope
(Currently README.md is wrong, fix later)
java -jar ScanReplace-<version>.jar [init]
Example:
java -jar ScanReplace-0.1.0.jar
java -jar ScanReplace-0.1.0.jar init
Download latest version on Release, type
java -jar ScanReplace-<version>.jar init
Following message will show in screen
file_key.json created
key_value.json created
scan_replace_config.json created
Change file_key.json
content to
{
"test.txt": ["key1", "key2"]
}
Change key_value.json
content to
{
"key1": "[It is key1]",
"key2": "[It is key2]"
}
Create test.txt
key1
key2
Type
java -jar ScanReplace-<version>.jar
Content of test.txt
will change to be
[It is key1]
[It is key2]
{
"filePath": ["key1", "key2"],
"...": ["..."]
}
filePath
in file_key.json
can refer under directory
e.g. dir1/dir2/test.txt
Only the key declare in file_key.json
to corresponding file will be scan and replace
{
"test.txt": ["key1", "key2"]
}
{
"key1": "[It is key1]",
"key2": "[It is key2]"
}
key1
key2
key2
in test.txt
will not be replace, because key2
not declare in file_key.json
to corresponding file
You can check out a example in example/key2-not-replace/
{
"key": "value",
"...": "..."
}
{
"file_key": "file_key.json",
"key_value": "key_value.json",
"output": "",
"file_prefix": "",
"file_suffix": "",
"key_prefix": "",
"key_suffix": ""
}
Define a path of file_key json, default is file_key.json
Define a path of key_value json, default is key_value.json
Define a path of output folder, default is empty ""
{
"..." : "...",
"output": "output/",
"..." : "..."
}
Leave it blank ""
will replace file in-place
You can check out a example in example/output-folder/
It is a global setting of file path with prefix and suffix
A common setting is prefix with some folder, to change the root of reference in file_key.json
file_suffix
is uncommon to use but provided
{
"..." : "...",
"file_prefix": "directory/",
"file_suffix": ""
}
All filePath
in file_key.json
will append prefix and suffix
{
"filePath1": ["key1", "key2"],
"filePath2": ["key1", "key2"]
}
equivalent to
{
"directory/filePath1": ["key1", "key2"],
"directory/filePath2": ["key1", "key2"]
}
It is a global setting of searching key with prefix and suffix
A common setting is prefix with <
and suffix with >
(or {{
and }}
)
{
"..." : "...",
"key_prefix": "<",
"key_suffix": ">"
}
All key in key_value.json
will append prefix and suffix
{
"key1" : "value",
"key2" : "value"
}
equivalent to
{
"<key1>" : "value",
"<key2>" : "value"
}
.\gradlew jar