Hello,
Iam new around and in the batch scripting world. iam having some issues to create a simple script to extract a value from a output i have.
Output similar to:
Files: 193368
Directories: 1003
Size: 5,459,286,921,170 bytes
Size on disk: 5,459,693,432,960 bytes
i want to take the value of the "Size" inside a variable so i can compare it. Problem is that ive made a few tries and didnt make it.
Was close to get it with:
for /f "tokens=2 skip=2 delims= " %%i in (file.txt) do echo [%%i]
but it returns me
[5,459,286,921,170]
[on]
...
and i cant move from here...
Can anyone give me and hand with this please.
Regards,
Arestas
I need to compare two sets of folder information
Moderator: DosItHelp
Re: Need some help with simple program
The task as you specify is simple enough, but you can't do a numerical compare with values over 2 GB using plain batch code.
If you reveal the actual task then one of us can waste their time to help you solve it.
If you reveal the actual task then one of us can waste their time to help you solve it.
Re: Need some help with simple program
Well, iam copying files from one file server to another using a robocopy script.
What i pretend is to compare source and destination by size. if they are the same send an email saying "task ended" and if they are not send a email saying "check folder".
To compare sizes iam using a batch script that will run when scripts ends that will call a windows tool called du. it will output the result to a *txt file with the following format:
Files: 193368
Directories: 1003
Size: 5,459,286,921,170 bytes
Size on disk: 5,459,693,432,960 bytes
So i now need to treat this output in order to get size of folder1 and folder2 and compare both.
Regards,
Arestas
What i pretend is to compare source and destination by size. if they are the same send an email saying "task ended" and if they are not send a email saying "check folder".
To compare sizes iam using a batch script that will run when scripts ends that will call a windows tool called du. it will output the result to a *txt file with the following format:
Files: 193368
Directories: 1003
Size: 5,459,286,921,170 bytes
Size on disk: 5,459,693,432,960 bytes
So i now need to treat this output in order to get size of folder1 and folder2 and compare both.
Regards,
Arestas
Re: Need some help with simple program
Iam moving some fileshare for new servers. For that iam using a robocopy script.
what i wanna implement is some kind of automatic validation. So i ve created a script to to check folder size at source and at destination using a windows tool called du.
That script will write 2 text files with the output you can see in the first post.
So now that i have the size of the source folder and destination folder i wanna compare them to send an alert email.
My problem is just to extract the size from the output, so i can compare them and create the alerts.
If i wasn't clear enough feel free to ask for more info.
Regards,
what i wanna implement is some kind of automatic validation. So i ve created a script to to check folder size at source and at destination using a windows tool called du.
That script will write 2 text files with the output you can see in the first post.
So now that i have the size of the source folder and destination folder i wanna compare them to send an alert email.
My problem is just to extract the size from the output, so i can compare them and create the alerts.
If i wasn't clear enough feel free to ask for more info.
Regards,
Re: Need some help with simple program
arestas wrote:To compare sizes iam using a batch script that will run when scripts ends that will call a windows tool called du. it will output the result to a *txt file with the following format:
Files: 193368
Directories: 1003
Size: 5,459,286,921,170 bytes
Size on disk: 5,459,693,432,960 bytes
A simple way is to compare the two outputs of DU if they show as your example above appears.
Another way is to check the errorlevel result of robocopy to see if there were any failures.
Further information about the task or DU output would be useful.
Re: Need some help with simple program
i would like to compare DU result, but only by the Size.
Any ideas on how can i extract only the value of the size from the 2 output files and compare them?
Any ideas on how can i extract only the value of the size from the 2 output files and compare them?
Re: Need some help with simple program
This is not the only way to do it - just one way.
Code: Select all
@echo off
type du1.txt|find "Size: ">"file1.txt"
type du2.txt|find "Size: ">"file2.txt"
fc /b "file1.txt" "file2.txt" >nul || echo send email coz stuff happened
del file?.txt
Re: Need some help with simple program
Tanks for all the foxidrive.
It works like a charm.
Regards,
Arestas
It works like a charm.
Regards,
Arestas