Showing posts with label batch file. Show all posts
Showing posts with label batch file. Show all posts

Monday, June 30, 2014

Extract quoted data from a text file using dos batch script

In some cases,  you may need to remove the quote that contains the value you want to extract. Here's the small piece of script I used to "clean up" the value.

--start of script ---
:DeQuote
for /f "delims=" %%A in ('echo %%%1%%') do set %1=%%~A
goto :eof
---end of script----

Usage:
Call :DeQuote <variable name>

Here's an example. 

------------value.txt-------------
"Gas"
"Labels"
"Schedule"
"Location"
"Options"
---------end of value.txt----------

Here's the script to clean up the files

-------------start of script-------------

SETLOCAL EnableDelayedExpansion

del /q out.txt

for /f %%i in (value.txt) do (
set tee=%%i
call :DeQuote tee
echo !tee! >> out.txt)

goto :eof

:DeQuote
for /f "delims=" %%A in ('echo %%%1%%') do set %1=%%~A
echo %1
goto :eof

----------end of script-----------------

You will be able to get out.txt as below

------out.txt--------------
Gas 
Labels 
Schedule 
Location 
Options 
---------------------------

Tuesday, July 9, 2013

Qvod Cache !mv files to rmvb ( Qvod快播(安卓)下载文件(!mv)合并方法)

If you have been using Andriod Qvod player, you will be a little bit frustrated if you want to move the downloaded file from your phone to a computer or other media player.

Qvod is a very fantastic application in Andriod which allows you to download Peer to Peer files very easily.

While there are a lot of Qvod cacher conversion program in the internet, you do not know if they are malware or contains virus.

I written this simple batch file in dos format, the key thing it is doing is to extract the number in the middle of the cache file name, expand that with leading zeros so that the system can sort the file names accordingly.

-----------Start of qvod.bat--------------
ren *.!mv *.

for /f "tokens=1,2 delims=_ " %%i in ('dir/b') do (


setlocal ENABLEDELAYEDEXPANSION


set ttt=000000000%%j
set ttt=!ttt:~-5!
ren %%i_%%j !ttt!.rmv
endlocal

)
)

setlocal ENABLEDELAYEDEXPANSION
set tttt=copy/b
for /f %%u in ('dir/b *.rmv') do (
set tttt=!tttt! %%u +
)

%tttt:~0,-1% result.rmvb

endlocal
-----------End of qvod.bat--------------