13 July, 2015

Check if name equals its IP via batch

Hi,

Had a problem that I had a server name and it's IP and needed to make sure that the IP did not change.

Here is a small script to do that, pass the name and IP as parameters and it will give you back errorlevel according to the check (0 for OK).

============================================================
FOR /f "tokens=1,3 delims=: " %%A IN ('ping -n 1 %1') DO IF %%A==Reply set ip=%%B

If %2==%ip% goto ok

exit /B 1

:OK

exit /B 0
============================================================


Enjoy

29 January, 2015

creating m3u playlist automatically

Hi,

I'm updating my USB stick very frequently and the new car I got does not allow folder browsing only playlists. - very annoying.

But, this is not something that will stop me... after a lot of testing a created the following script, it will create a M3U file in each sub-directory (for now it only works with one level down).

So, there is PlayListCreator-Step1.cmd:
==========================================
del *.m3u /S /Q
dir /B /AD >DirList.txt

for /f "tokens=*" %%A in (DirList.txt) do (PlayListCreator-Step2.cmd "%%A")
==========================================

And PlayListCreator-Step2.cmd:
==========================================
set root=%__CD__%
cd %1
dir /b /o:n *.mp3 > "%~1.m3u"
cd /d %root%
==========================================

Just save the content between the === to files and run PlayListCreator-Step1.cmd.


Enjoy...