I want to use Mediainfo with a bat file.
It should write the Media Info into a textfile, then rename the file to *.nfo
That works quite good, but I always get the complete "standart" Media Info, not a custom one that I need.
Here is my code so far:
#echo off
set "mediainfo_path=C:\Program Files\mi cli\MediaInfo.exe"
set "output_extension=C:\Program Files\mi cli\custom.txt"
cd %1
echo.
echo Looking for Media Assets on target directory . . .
REM ******** Add media file extensions here ********
dir *.mkv /b /s > filelist.tmp
REM *
REM ******* Loop through temporary file list *******
(for /f "delims=" %%i in (filelist.tmp) do (
echo Extracting %%i metadata information . . .
setlocal enabledelayedexpansion
"!mediainfo_path!" --logfile="!output_extension" "%%i" > %%i.nfo
echo()
endlocal
)
del filelist.tmp
echo.
o matter what "output_extenstion" I choose, the result is always the same, full log.
First, you need to do step by step, so start by trying the MediaInfo command without the batch stuff. You'll see that it does not work.
"--logfile" is for storing the output (similar to your ">%%i.nfo") so you did not say to MediaInfo that you want a custom report.
mediainfo --Output=file://custom.txt a.mkv >a.nfo
or
mediainfo --Output=file://custom.txt a.mkv --LogFile=a.nfo
Would work as you expect (the first version both show and store info, the second version only store info).
So replace the "MediaInfo line" by:
"!mediainfo_path!" "--Output=file://!output_extension!" "%%i" > %%i.nfo
and it works as you expect.
Note: I am aware that there is a lack of documentation, due to lack of time :(.
Jérôme, developer of MediaInfo
I am trying to create a folder using batch file. The folder name should be in a format - yyyymmdd-hhmm .I got started with the below code but I get yyyymmdd- as one folder and hhmm as another folder. But when I tried it after 13.00 hrs I get yyyymmdd-hhmm format. Why is there a different behaviour during 9:45 in the morning. I don't know. Any help appreciated.
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c%%a%%b)
For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set mytime=%%a%%b)
mkdir %mydate%-%mytime%
I get 1 folder -> 20160810- and another folder -> 945.
"I get 1 folder -> 20160810- and another folder -> 945."
That's because of the space, so mkdir sees two parameters and so creates two folders.
Either put qoutes around the new foldername
mkdir "%mydate%-%mytime%"`
or (maybe better) replace the space with a zero:
mkdir %mydate%-%mytime: =0%
putting qoutes around anyway doesn't harm:
mkdir "%mydate%-%mytime: =0%"
(btw: there is a way to get a date-time-string independent of local settings)
I have a project where I need to prove the virtue of a degausser to erase completely all traces of files on a standard HDD. I want to propagate the subject HDD with repetitive information, such as a single word "information".
I am thinking, in this way, I can conduct a search of the degaussed drive very quickly to prove the excellence of the process. As a part of my security requirements, programs like dBan and such are less desirable than a process that will destroy the media's ability to function for storage and any retrieval. The environment the degausser would be used in, should it prove it's integrity, also limits physical destruction of the storage media.
The .bat file I wish to create should contain a recursion that will effect the size of the file being copied so as to incrementally increase the amount of data transfer thereby decreasing the time to fill the drive.
I've used the following and so far the process slows to a crawl after a very (relative) short time. I've experimented with the use of '%' before and after ERRORLEVEL and it seems with the % symbol the program fails early in process. Anyone have any ideas? Here's the script I've been using and the specs of the computer I'm trying this process through:
P4, 1GB Ram, 2.8GHz
echo off
Rem Setting home folder
C:
Rem Setting Home folder again
cd\
:copy repeat
rem Using date and time so it formats the file IT_20130708_Time in hours minutes and milliseconds
set hr=%time:~0,2%
if "%hr:~0,1%" equ " " set hr=0%hr:~1,1%
COPY "IT.txt" "C:\testcopy\IT_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%hr%%time:~3,2%%time:~6,2%%RANDOM%.txt"
COPY "IT.txt" "C:\testcopy2\IT_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%hr%%time:~3,2%%time:~6,2%%RANDOM%.txt"
COPY "IT.txt" "C:\testcopy3\IT_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%hr%%time:~3,2%%time:~6,2%%RANDOM%.txt"
COPY "IT.txt" "C:\testcopy4\IT_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%hr%%time:~3,2%%time:~6,2%%RANDOM%.txt"
COPY "IT.txt" "C:\testcopy5\IT_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%hr%%time:~3,2%%time:~6,2%%RANDOM%.txt"
COPY "IT.txt" "C:\testcopy6\IT_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%hr%%time:~3,2%%time:~6,2%%RANDOM%.txt"
COPY "IT.txt" "C:\testcopy7\IT_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%hr%%time:~3,2%%time:~6,2%%RANDOM%.txt"
COPY "IT.txt" "C:\testcopy8\IT_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%hr%%time:~3,2%%time:~6,2%%RANDOM%.txt"
COPY "IT.txt" "C:\testcopy9\IT_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%hr%%time:~3,2%%time:~6,2%%RANDOM%.txt"
COPY "IT.txt" "C:\testcopy10\IT_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%hr%%time:~3,2%%time:~6,2%%RANDOM%.txt"
rem if it Does not error GOTO the start aka :copy repeat
IF ERRORLEVEL ==0 GOTO copy repeat
rem end this file if error
goto end
:end
The intent in the above is to continue copying the next group of files even if there is a failure in the copy operation. Also, the process needs to be accomplished in as short a time as possible. I sincerely appreciate all suggestions, thank you for your time and considerations.
One issue you will find (FAT32, myabe NTFS too) is that with large numbers of files in a folder, it takes longer to create new files. You should look at creating a new folder every say 50,000 files.
The size of the file being copied is a factor as small files are very inefficient - so this creates a ~27 MB file to copy with INFORMATION repeated inside it.
There are a finite number of root directory entries in some drive formats so this creates one root folder and then subdirectories inside that.
This might work for you:
#echo off
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set dt=%%a
set stamp=%dt:~0,8%-%dt:~8,6%
del it.txt 2>nul
echo creating string
for /L %%a in (1,1,500) do call set var=%%var%%INFORMATION
echo creating it.txt file (45 seconds...)
for /L %%a in (1,1,5000) do (set /p =%var%>>IT.TXT <nul)
for /L %%a in (1,1,2000000000) do call :next %%a
pause
goto :EOF
:next
set folder=00000000000%1
set folder=%folder:~-10%
set folder=c:\testcopy\testcopy-%folder%
md %folder% 2>nul
set c=0
:loop
set /a c=c+1
echo %folder%-%c%
copy it.txt %folder%\IT_%stamp%_%random%%random%%random%%random%.txt >nul
if %c% EQU 50000 goto :EOF
if not errorlevel 1 goto loop
goto :EOF
The following few lines output the names of certain files in a folder, a delimiter, and a timestamp.
for /f "eol=: delims=" %%F in (
'dir /b /a-d /one *.txt *.pdf *.doc* *.xls* *.msg 2^>nul'
) do echo %indent%%fileBullet% %%F%delimeter% %%~tF
So, produces something like this
Response.docx; 02/07/2013 12:13 PM
I'd like to remove the time portion of the timestamp (so date only), followed by how many days old the file is. So
Response.docx; 02/07/2013; 14
I've found some fairly lengthy solutions online that contain a dozen or so lines. Is there a short and sweet approach?
Here's something shorter and sweeter. It's not as short and sweet as you'd like, but at least it's not 12 lines of code. :)
for /f "eol=: delims=" %%F in (
'dir /b /a-d /one *.txt *.pdf *.doc* *.xls* *.msg 2^>nul'
) do call :datediff "%indent%%fileBullet% %%F%delimeter%" %%~tF
goto :EOF
:datediff
echo wscript.echo DateDiff^("d", "%2", Date^(^)^)>"%temp%\dd.vbs"
set /P i="%~1 %2%delimeter% "<NUL
cscript /nologo "%temp%\dd.vbs"
del /q "%temp%\dd.vbs"
I am trying to write an aspx page which will crawl through a directory and find all the files contained within. I think I have that part down.
Is it possible to read to a string without first creating .txt files from the html and asp pages I'm reading through? I don't want to create a ton of new files and then end up having to delete them later.
Ultimately, I'm trying to develop a tool to search through an entire directory and find all the image tags which have empty alt attributes or no alt attributes. I wrote some jQuery which can find the tags, and I have also written the part that searches through a directory.
If you have a file on your filesystem, you can simply read it - if you know it is a textual format, you need to use a stream with the correct encoding to do this.
Since you are reading and querying HTML, I suggest using a library that is specifically written for this task - the HTML Agility Pack - you can give it the path to the HTML file and then query it for all img elements. The source download comes with sample projects that will show you how to achieve this and other tasks.
Link:
http://msdn.microsoft.com/en-us/library/system.io.streamreader.aspx
Example:
http://www.csharp-examples.net/load-text-file-to-string/
(this example shows how to work with .txt files, but I believe if you can put any other extension)
Getting all files:
http://www.csharp-examples.net/get-files-from-directory/
Edit: and don't forgot about encoding.
sure, why not save to environment variables, no fuss, no mess. so try something like this:
will take apart an html or asp file and save to an array of variables, i have shown you how to put it back together as well.
let me know how if this is a solution for you
#echo off
setlocal EnableDelayedExpansion EnableExtensions
echo.
set count=0
if exist newfile.html del newfile.html
:: to unassemble
for /f "tokens=*" %%a in (filename.html) do (
echo %%a
set /a count=count + 1
set htmllinenum!count!=%%a
)& set finalcount=!count!
:: to assemble
for /l %%a in (1,1,%finalcount%) do (
echo !htmllinenum%%a!>>newfile.html
)
notepad newfile.tmp
set count=0
if exist newfile.asp del newfile.asp
:: to unassemble
for /f "tokens=*" %%a in (filename.asp) do (
echo %%a
set /a count=count + 1
set asplinenum!count!=%%a
)& set finalcount=!count!
:: to assemble
for /l %%a in (1,1,%finalcount%) do (
echo !asplinenum%%a!>>newfile.asp
)
notepad newfile.asp