Removing “enter” character with batch?
-
21-12-2019 - |
Question
I use a tool called "exiftool" for reading metadata information from video file for Listing/Categorization. Exiftool output is something like this.
1920x1080
2:58:09
12421 MB
What I want is;
[1920x1080][2:58:09][12421 MB]
This is what I am trying to do for removing "enter" character;
:_Dongu2
set GELEN=%~1
set /a SAYAC2+=1
if %SAYAC2% LEQ 99 (
if %SAYAC2% LEQ 9 (
title Ilerleme Durumu: 00%SAYAC2% / %FSAY%
) else (
title Ilerleme Durumu: 0%SAYAC2% / %FSAY%
)
) else (
title Ilerleme Durumu: %SAYAC2% / %FSAY%
)
setlocal DisableDelayedExpansion
set "firstLineReady="
(
for /F "eol=$ delims=" %%a in ('exiftool -s3 -ImageSize -Duration -FileSize "%~1\%GELEN:~20,-23%.mp4"') DO (
if defined firstLineReady (echo()
set "firstLineReady=1"
<nul set /p "=%%a"
)
)>> out.txt
goto :EOF
So far I didn't work it out. I found this function from Jeb's answer on another question. This is the way I call this function
(for /f "tokens=*" %%x in (%MTEMP%) do call :_Dongu2 "%%x") && title %NAME%
and %MTEMP%
file is like
Z:\Movies\000y.001y\The.Lord.of.the.Rings.The.Fellowship.of.the.Ring.(2001){0120737}[00085]
Z:\Movies\000y.001y\The.Lord.of.the.Rings.The.Return.of.the.King.(2003){0167260}[00087]
Z:\Movies\000y.001y\The.Lord.of.the.Rings.The.Two.Towers.(2002){0167261}[00086]
each movies attitude had to be on another line. out.txt had to be like;
[1920x1080][2:58:09][12421 MB][The.Lord.of.the.Rings.The.Fellowship.of.the.Ring]
[1920x1080][3:02:31][14660 MB][The.Lord.of.the.Rings.The.Return.of.the.King]
.
.
.
Solution
Here's a batch solution:
@echo off
<"file.txt" (
set /p a=
set /p b=
set /p c=
)
echo [%a%][%b%][%c%]
Output:
[1920x1080][2:58:09][12421 MB]
OTHER TIPS
Directly ask exiftool to produce the required output
exiftool -p [${ImageSize}][${Duration}][${FileSize}] videoFile.mp4
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow