0

I currently have a batch file to create an nfo of all file inside a folder. Now I'm looking to add a function for a "single file". i have a part that works but the nfo file text includes the path of the file in the "Complete name" line. I would like to know how to not display this path before the filename. The nfo is currently saved at the location of the file, it should stay that way.

there is the batch file (without the "if single file") : Tx to @Compo for this.

@Echo Off
SetLocal EnableExtensions

Set "MIExe=%UserProfile%\Standalone\MediaInfo\MediaInfo.exe"
Set "OutExt=nfo"
Set "HR=------------------------------------------------------------------"

For %%G In ("%~1") Do If "%%~aG" Lss "d" (If "%%~aG" GEq "-" (
        Echo Error! File arg.
        GoTo EndIt) Else (Echo Error! Invalid directory arg.
        GoTo EndIt)) Else If "%%~dG" == "" (
    Echo Error! Full directory path required.
    GoTo EndIt)

If Not Exist "%MIExe%" (Echo Error! MediaInfo not found.
    GoTo EndIt)

PushD "%~1"

Set "ExtLst="
For %%G In (aac ac3 aifc aiff ape asf au avi avr dat dts flac iff ifo irca m1v
    m2v mac mat mka mks mkv mov mp2 mp3 mp4 mpeg mpg mpgv mpv ogg ogm paf pvf qt
    ra rm rmvb sd2 sds vob w64 wav wma wmv xi) Do If Not Defined ExtLst (
    Set "ExtLst=".":"*.%%G"") Else Call Set "ExtLst=%%ExtLst%% ".":"*.%%G""

Set "}=%PATHEXT%" && Set "PATHEXT="
%SystemRoot%\System32\where.exe /Q %ExtLst%
If ErrorLevel 1 (Echo Error! Directory has no supported files.
    GoTo EndIt)

Set "i="
(For /F "Delims=" %%G In ('%SystemRoot%\System32\where.exe %ExtLst% 2^> NUL'
) Do (If Defined i Echo %HR%
    "%MIExe%" "%%~nxG"
    Set "i=T")) 1> "%~nx1.%OutExt%"

:EndIt
%SystemRoot%\System32\timeout.exe /T 3 /NoBreak 1> NUL
GoTo :EOF

i want to add this part with a if it's a file not folder :

:SingleFile
"%MIExe%" "%~1" > "%~1.%OutExt%"

This work but produce a full path with name at the "Complete name" line..

And i also like to know if the "is a file check" can be use with this part (at the start of the batch) :

...
If "%%~aG" GEq "-" (
        Echo Single file.
        GoTo SingleFile
...

Thanks in advance for your help !

  • 2
    If you remember the advice I provided at the top of my answer, the trick is to use the filename only as the input to `mediainfo.exe`. The method I used was to change directory to that of the files, then use just the filename. So using the same mechanism, you could `PushD "%~dp1"`, then use `"%MIExe%" "%~nx1" 1> "%~n1.%OutExt%"`, _(if you want the same filename with the `.nfo` extension)_. – Compo Feb 16 '21 at 01:34
  • Please consider posting a [mcve] in the future. This certainly does not represent minimal. – Squashman Feb 16 '21 at 04:07
  • Tx a lot, verry simple indeed ! i was able to do the batch with a simple if else with : [This reply]https://stackoverflow.com/a/8669636/2276368 (last update) – user2276368 Feb 16 '21 at 22:45

0 Answers0