Create Batch Script to Scan Multiple Files [closed] - for-loop

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 months ago.
Improve this question
I'm looking to make a batch script. What I have is a ton of different logs in a ton of different places, all with a bit of important info and a lot of useless info.
Some of these logs are directly named, and some are named by date and time.
I'm trying to make a script that can basically scan them for me so I don't have to go through each folder and log and scan manually.
Some examples:
OmegaManager\logs\omega.log - scan for "State:" and "has been updated"
OmegaManager\logs\instance-0.log - scan for "shutdown"
KRBanking\PlayerDatabase*logs are numbers* - copy all information or scan for changes since last time?
KRBanking\ServerLogs*logs are dates and times* - scan for "Deposited" and "Withdrawed"
And then output the whole line.
Is this even moderately possible? Thanks in advance.

Yes, this is possible. Batch files support loops, conditions, and filtering/searching.
A FOR loop allows you to iterate through files or directories, you'll find more information in this SO post.
To find strings in a file, you have several options, i.e. find and findstr, see riptutorial.com:
FIND can scan large files line-by-line to find a certain string with no wildcard support.
FINDSTR has more features and supports regular expressions with wildcards in the search string.
Super simple example for one of your use cases
The batch script must be placed where your files are. Otherwise, you need to add a full path instead of just "omega.log".
FINDSTR /L /C:"State:" /C:"has been updated" omega.log
To start with batch programming, you can read the findstr documentation and some tutorials.

Related

Search / replace in bash script with dynamic part [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I'm writing a bash script and I want to edit a PHP config file, find a string and replace by another.
The hard part is that I want this search/replace to be dynamic.
Here is an example:
define('APP_VERSION', '1.0.31');
The goal is to replace 1.0.31 by another version number.
How could I achieve that? I've tried with sed, but can't isolate the version number part (because it's not always the same, so I can't directly search for 1.0.31)
Thanks
The point of regexes is to match non-static text. To replace any version number with 123 use
sed "s/define('APP_VERSION', *'[^']*')/define('APP_VERSION', '123')/"

Nifi: how to use fileFileter for fetching files from hadoop? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I want to fetch files from hadoop directory based on their filename,logically it looks like this ${filename}.* (because i have several files with similar name they look like this 2011-01-01.1 , 2011-01-01.2 etc.) i tried to use listhdfs+fetchhdfs but they can't match my logic
Can you give me any batter idea how can i do it inside nifi environment?
is it possible to make this task by groovy code inside ExecuteScript processor ?
how can i connect hdfs directory by groovy code ?
after getting this files i should put them in a flowfile list and can't transfer flowfiles untill flowfile list size hasn't matched the value of count attribute( placed in flowfile)
Salome,
Using ListHDFS can list out every files present in HDFS.
Afterwards you can use "RouteOnAttribute" to match files with below pattern then you can fetch those files.
${filename:matches('\d{4}-\d{2}-\d{2}.\d')}
Now it matches with files present in HDFS and it comes in matched route.
Next use FetchFile after RouteOnAttribute to be matched.
Here you can use fetch files with pattern"\d{4}-\d{2}-\d{2}.\d"
It will fetch your required files only.

Make a list of files in a directory (Batch)? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I'm trying to make a list of items in the "C://Program Files" directory, but I'm new to Batch and I'm unsure of how I would do this. I'm more familiar with high-level languages like Java and scripting languages like Lua, but recently I've wanted to learn low(er)-level languages like Assembly and Batch (if you can actually count Batch as a language...).
How would I do this?
I've already changed the directory to the Program Files folder but I have no idea how to make a list of files (from my time in languages like Lua I know I'll need to use a For loop, but I'm unsure of how to do this).
Thanks!
Take a look at the DIR command DIR /?
Dir /b *.* >list.txt
Typing in Dir C:***\ (the rest of the path) will list all the items in that specific folder.

Many requestShippingRates errors [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I cannot seem to find out how to track down this bug: I can see it has something to do with Shipping Rates, but there's very little information being posted into the error log.
2013-01-08T15:45:36+01:00 DEBUG (7): requestShippingRates
There are many of these errors being posted.
If you have shell access, try using the following command to search for instances of requestShippingRates. Run it from your /var/www/app directory. the * means look at everyting, the -R means recurse directories, and the -i means ignore upper / lowercase.
grep "requestShippingRates" * -R -i
You did not mention whether or not these errors are showing up in your php log, but you could also grep the following:
grep "error_log(" * -R -i
That will show anything written to the php error log.
There are a couple of possibilities, one is that the string is contained in your code, so simply searching the project for 'requestShippingRates', and find the one that is a string being passed to Mage::log. The other, which is probably more likely, is that at some point somebody has put something along the lines of Mage::log(__FUNCTION__) in one of the requestShippingRates functions. You should be able to find that easy enough by searching for n requestShippingRates (i.e. match the n at the end of a function declaration).

How to convert .nii to .nii.gz file? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have lots of .nii file. I want to know how to convert .nii file to .nii.gz file?
Thanks
As far as I know, there is nothing special about zipping NIfTI files. In MATLAB, you could simply do:
gzip('niftifilename.nii') % this will return niftifilename.nii.gz
gzip('*.nii') % for multiple nii files to create one .nii.gz
To work with the file again, you can unzip it, using gunzip. I've tried this on my Mac (don't know if this will work on Windows).
Typically, they are volume data, and hence take up a fair bit of disk space. Zipping it is purely for reducing the size of the file, and should not modify data.
You can simply do:
gzip({'*.nii'},outputdir)
Which will zip all your nii files into a nii.gz and place it into outputdir.
From the documentation:
To gzip all .m and .mat files in the current directory and store the
results in the directory archive, type:
gzip({'.m','.mat'},'archive')

Resources