Sunday, February 7, 2016

SRT to VobSub

I bought a TV: Panasonic ET60 very nice but it does not handle subtitles very well, or I mean it is very limited (very small font, and not possible to change colors)

The solution would be to either hard copy the subtitles or use vobsub subtitles (idx+sub / vobsub is supported on this TV, I guess many DVD players and other Smart TV would be in the same conditions).

So I found two good solutions txt2vobsub or subtitlecreator.
I prefer subtitlecreator because the fonts look slightly better, but maybe that just me.
And finally use mkvmerge (incredible tool) to pack all together.

So I created two scripts, one for each case, you would need to download/extract and add that directory to your path (System environment) or you could copy all the files everytime.
Then copy for each case the .cmd to the directory where you have the movie and subtitle.
The script will look for .mp4 and .srt (same filename). You could edit or rename based on your preference.

(if you want to modify the font and size: for txt2vobsub just edit the batch fule and replace the name, I think it is set to Arial 24, if you want do this for SubCreator go to the data subfolder, edit the profile.xml, edit colors by changing the palette colors in hex format, this will also let you position the subtitle as required, with these settings it will work for 720p movies in general).

Download link: https://mega.nz/#F!GdsFAIJZ!PYvbKNfWL_ZpVEfTJogn2w


0 comments:

Post a Comment

Wednesday, May 6, 2015

Add the filename to each start of line on a file with SED

So you have a text file where you want to add the filename on each start of line for some reason so it can be easily managed as a csv or on Excel.

So do a dir /b > on the directory or create a list of files that require the filename as the begining of each line on those files:

In my example I have a bunch of file names inside asd.txt

for /f "tokens=*" %%i in (asd.txt) do sed "s/^/%%i;/" %%i

or

for /f "tokens=*" %%i in (asd.txt) do sed -i "s/^/%%i;/" %%i

That will add the filename and a semicolon

Such as:
file1;line1
file1;line2

And so on.


0 comments:

Post a Comment

Thursday, April 23, 2015

Findstr regexp to find subfolders of shares 3rd level

Findstr regexp quick note:
As you may know regexp or regular expressions are there to ease our work
Using awk,sed is very common. But it can also be used to quickly search some patterns in windows native command findstr.
If you are not familiar with regexp it is like telling your computer you want to search some patterns instead of a literal search.
Literal search would be: dir file.txt : file.txt is the filename
Regexp search would be: dir *.txt : the asterisk is part of the regexp search, it is a very silly simple example but you understand the idea.

So for example you have a list of directories or shares.
And what you need is to find only the subfolders, at the 3rd level.
You can you use findstr in this way:
type shares-with-quotes.txt | findstr /r /c:"\\\\.*\\.*\\.*"

From input:
\\server1\share1
\\server2\share2
\\server1\share1\subfolder1
\\server2\share2\subfolder1

type shares-with-quotes.txt | findstr /r /c:"\\\\.*\\.*\\.*"
Only this will be filtered:
\\server1\share1\subfolder1
\\server2\share2\subfolder1

And if you want the opposite do somethink like:
type shares-with-quotes.txt | findstr /r /v /c:"\\\\.*\\.*\\.*"
\\server1\share1
\\server2\share2

Note: "\" has to be doubled because of the regexp notation so a literal "\" needs to be stated as "\\", you will have to escape some special characters like this or dot, asteriks, etc

0 comments:

Post a Comment

Tuesday, February 24, 2015

AWK remove last Carriage Return

When you are manipulating text sometimes you may want to go back to the last line which had text:
So the next line will delete any carriage return until it reaches text:

awk "BEGIN{ORS=\"\"}{print n $0}!n{n=\"\n\"}" asd.txt

0 comments:

Post a Comment

Monday, January 26, 2015

Network settings: only want to change a DNS server ip address on a client computer Remotely / No interface or NIC name is required

So a Domain Controller/DNS server went down and the plan was to actually retire that server anyways.

We wanted to change the DNS Setting very fast. (replace the primary dns server on a large number of servers with another ip address).
I found this very nice script and decided to ran this as a test on a few servers, but from 96 machines it worked on 48 only (apparently the ping function did not work very well on some of our servers).
So I asked my coworker Seba Bistakis to create a similar VBS script.

Now we also wanted to avoid potential issues like a server down, or wmi not responding, access denied. So I created a so called "wmiPing" script in batch:
You will need Unix/Linux sed port which you can locate on some previous posts or any port on Internet, but this is only to extract those that failed.
======================================================================
for /f %%i in (lista.txt) do wmic /node:%%i os get | find /i "Windows" || echo %%i>>Falla.txt
copy lista.txt refiltrado.txt /y
for /f %%i in (Falla.txt) do sed -i "/%%i/Id" refiltrado.txt
del sed*.
======================================================================
(if you prefer to remove them manually you can just remove the last loop to run sed).
So the file refiltrado.txt is the one which we know wmi is working, we will use the content of that file.

And my coworker created a script to be ran locally, which I modified a little bit to be run remotely,
dns_change.vbs:
======================================================================
'Author(s): Seba Bistakis & Edu Nakama
Set objShell = WScript.CreateObject("WScript.Shell")
strFilename = "lista.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTS = objFSO.OpenTextFile(strFilename)
Set objFSO2 = CreateObject("Scripting.FileSystemObject")
outFile = "lista1-executed.txt"
objFSO2.DeleteFile(outFile)
Set objFile = objFSO2.CreateTextFile(outFile,ForAppending,True)

Do Until objTS.AtEndOfStream

On Error Resume Next

strComputer = objTS.ReadLine

wscript.echo "============================"

Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

If Err Then
 wscript.echo strComputer & ";Error;" & err.number & ";"
 Set objWMIService = Nothing
End If
On Error Goto 0

If Not objWMIService Is Nothing Then
objFile.Writeline strComputer
 Set colNicConfigs = objWMIService.ExecQuery _
  ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
 For Each objNicConfig In colNicConfigs
  If Not IsNull(objNicConfig.DNSServerSearchOrder) Then
   dns = objNicConfig.DNSServerSearchOrder
   For i = 0 To UBound(dns)
    wscript.echo strComputer & ";DNS" & i+1 & ";" & dns(i) & ";"
    If dns(i) = "10.261.40.23" Then
     dns(i) = "10.261.171.25"
     wscript.echo strComputer & ";DNS" & i+1 & ";" & dns(i) & ";CHANGED;"
    End If
   Next
   objNicConfig.SetDNSServerSearchOrder(dns)
  End If
 Next
End If

Loop
objFile.Close
objTS.Close
======================================================================
As you can see you will need to enter a each server on after another (one each line) on a filed called "lista.txt"

Run the script as cscript dns_change.vbs > Results.csv

Result.csv is the direct output of the script. As it is formated in CSV it can be opened on excel.
Lista1-executed.txt is a list of servers where the script was able to run on. If one is missing is because it couldn't ran on it.

Worked on: Windows 2003, Windows 2008, Windows 2012 servers.


0 comments:

Post a Comment