Metadata for batch files
Posted: 29 Oct 2016 11:59
Hello! Until today, we've all been storing batch file data in other files, making portability of data harder. Today I bring to you a simple solution that stores metadata inside of a batch file, so you don't create any files but you still store data. The following technique only requires some extra coding at the end of your batch file - and at the very end.
Just make sure to put this little bit of code at the end of your batch file and you're done! You can now store metadata inside of your batch file.
It's very easy. Here's an example batch file storing metadata
If you would like to use metadata, put this when you'd like to store data.
You have to put those comments after you use metadata because metadata is in it's early stage, and hasn't fully developed to it's best yet, and it makes weird output on the screen I'm sure any user wouldn't want to see. After you use metadata, make sure to re-output everything you already had on screen because it makes some funky noises as it's doing stuff (aka outputs text on screen)
If you would like download the working examples, please download the attachment below. The attachment below also contains the source code of metadata.bat
NOTE: metadata.bat is VERY BAD AND UNSTABLE as of right now. Please help out and make it better, if possible at all.
Code: Select all
::Metadata solution provided by SirJosh3917.
::Honestly I don't care for credit anywhere
::viewable in the batch file, but if possible just
::leave the first comment.
:metadata
if NOT EXIST metadata.bat (
(
echo.77u/QGVjaG8gb2ZmDQpjb3B5ICV+MyB0bXAuYmF0DQpAZWNoby4+JX4zDQpmb3Ig
echo.L2YgImRlbGltcz0iICUlYSBpbiAoIHRtcC5iYXQgKSBkbyAoDQoJaWYgIiUlYSI9
echo.PSJlY2hvLmE+bnVsJmV4aXQgL2IiICgNCgkJQGVjaG8uc2V0ICV+MT0lfjIgPj4l
echo.fjMNCgkpIGVsc2UgKA0KCQlAZWNoby4lJWE+PiV+Mw0KCSkNCikNCkBlY2hvLmVj
echo.aG8uYV4+bnVsXiZleGl0IF4vYj4+JX4zDQo=
)>tmp.bat
certutil -decode tmp.bat metadata.bat>nul
del /f /s /q tmp.bat>nul
cls
)
::METADATA FOR BATCH FILE
echo.a>nul&exit /b
Just make sure to put this little bit of code at the end of your batch file and you're done! You can now store metadata inside of your batch file.
It's very easy. Here's an example batch file storing metadata
Code: Select all
@echo off
title MetaData Example
call :metadata
del /f /s /q tmp.bat>nul
cls
IF NOT DEFINED name goto :GetName
echo.Oh hello %name%^! It's nice to see you again.
pause
exit
:GetName
echo Hello! What is your name?
set /p name=^>
echo Hello %name%^! Nice to meet you.
call metadata.bat name "%name%" "%~0"
::
::Always put this after you use metadata.bat
::
cls
echo Hello! What is your name?
echo.^> %name%
echo Hello %name%^! Nice to meet you.
echo I'll see you next time!
pause
goto :eof
::Metadata solution provided by SirJosh3917.
::Honestly I don't care for credit anywhere
::viewable in the batch file, but if possible just
::leave the first comment.
:metadata
if NOT EXIST metadata.bat (
(
echo.77u/QGVjaG8gb2ZmDQpjb3B5ICV+MyB0bXAuYmF0DQpAZWNoby4+JX4zDQpmb3Ig
echo.L2YgImRlbGltcz0iICUlYSBpbiAoIHRtcC5iYXQgKSBkbyAoDQoJaWYgIiUlYSI9
echo.PSJlY2hvLmE+bnVsJmV4aXQgL2IiICgNCgkJQGVjaG8uc2V0ICV+MT0lfjIgPj4l
echo.fjMNCgkpIGVsc2UgKA0KCQlAZWNoby4lJWE+PiV+Mw0KCSkNCikNCkBlY2hvLmVj
echo.aG8uYV4+bnVsXiZleGl0IF4vYj4+JX4zDQo=
)>tmp.bat
certutil -decode tmp.bat metadata.bat>nul
del /f /s /q tmp.bat>nul
cls
)
::METADATA FOR BATCH FILE
echo.a>nul&exit /b
If you would like to use metadata, put this when you'd like to store data.
Code: Select all
call metadata.bat name "%name%" "%~0"
::
::Always put this after you use metadata.bat
::
You have to put those comments after you use metadata because metadata is in it's early stage, and hasn't fully developed to it's best yet, and it makes weird output on the screen I'm sure any user wouldn't want to see. After you use metadata, make sure to re-output everything you already had on screen because it makes some funky noises as it's doing stuff (aka outputs text on screen)
If you would like download the working examples, please download the attachment below. The attachment below also contains the source code of metadata.bat
NOTE: metadata.bat is VERY BAD AND UNSTABLE as of right now. Please help out and make it better, if possible at all.