Solved Please help me make bat file to process all files in a folder

ironmine

New member
Local time
5:28 AM
Messages
3
Hello

I have downloaded a simple program (consisting of only one file - enc.exe) which can compress one audio format to another, even though the file extension stays the same.

It can be controlled through a cmd window with lines like this:

E:\Enc.exe -i uncompressed.dff -o compressed.dff

It's very tiresome and time consuming to convert each file in a folder in such manual mode.

Can you please teach me how to write a bat file which would make this program convert ALL the files with the extension dff in the current folder and place the resulting files in a subfolder with the same names as before.

Here's an example:

I copy enc.exe (and the bat file which I hope you'll help me create) to a folder called "Michael Jackson" which contains the following files:

01 - Song 01.dff
02 - Song 02.dff
03 - Song 03.dff
...

I want to be able to double click the bat file and get a subfolder (let's say, named as "dst") which would contain the compressed files with the same names:

01 - Song 01.dff
02 - Song 02.dff
03 - Song 03.dff
...

Any help would be very much appreciated!

Thank you
Eugene K
 

My Computer My Computer

Computer type
PC/Desktop
OS
Win7 Ultimate 64 bit
Hi Ironmine,

I've attached a batch file to this post. Place the batch file in with the .dff files, then either double click the batch script, or drag and drop a desired destination folder onto it.

(I may be able to shorten the script if you can verify to me that the Enc program accepts a relative output location. E.g. Does Enc.exe -i uncompressed.dff -o "New Folder\compressed.dff" work?)


Preview:
Code:
REM You may drag and drop a destination folder onto this batch file.
@echo off
setlocal EnableDelayedExpansion
pushd "%~dp0"

::
set file_mask="*.dff"
set enc="E:\Enc.exe"
set default_output_directory=\dst
::
set TMP_EXT=.TMP%RANDOM%%RANDOM%
::

if "%~1"=="" ( set output_directory="%~dp0\%DEFAULT_OUTPUT_DIRECTORY:"=%") else ( set output_directory=%1)

if not exist %OUTPUT_DIRECTORY% md %OUTPUT_DIRECTORY%
for /f "delims=" %%A in (' dir /b %FILE_MASK% ') do (
	for /f "delims=" %%G in ('echo."%%~dpA\%%~nA%TMP_EXT%%%~xA"') do ( set enc_out__FULLNAME=%%~fG& set enc_out__NAMEEXTN=%%~nxG)
	%ENC% -i "%%~fA" -o "!ENC_OUT__FULLNAME!"
	move "!ENC_OUT__FULLNAME!" %OUTPUT_DIRECTORY%\"%%~nxA"
)

popd
exit /b 0
 

My Computer My Computer

Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Pyprohly, thank you very much! It seems to be working! You are a genius.

This is a DSD2DST encoder which I mentioned: mpeg4dst.7z
 

My Computer My Computer

Computer type
PC/Desktop
OS
Win7 Ultimate 64 bit
I don't own any .dff files to test with, but if you like you can try out this (see attached) shorter version for yourself. If not, I'm glad the above batch file achieves what you want.


Remember to mark the thread as solved when you feel your question has been answered.

And Welcome to Sevenforums, Ironmine. :)


Preview:
Code:
REM You may drag and drop a destination folder onto this batch file.
@echo off
setlocal EnableDelayedExpansion
pushd "%~dp0"

::
set file_mask="*.dff"
set enc="E:\Enc.exe"
set default_output_directory=\dst
::

if "%~1"=="" ( set output_directory="%~dp0\%DEFAULT_OUTPUT_DIRECTORY:"=%") else ( set output_directory=%1)
if not exist %OUTPUT_DIRECTORY% md %OUTPUT_DIRECTORY%
for /f "delims=" %%A in (' dir /b %FILE_MASK% ') do (
	%ENC% -i "%%~fA" -o "%OUTPUT_DIRECTORY%\%%~nxA"
)

popd
exit /b 0
 

My Computer My Computer

Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Pyprohly,

The bat script you suggested does indeed work, thank you very much for it, the problem is that this encoder has turned out to be so slow, it is unusable for any practical purpose.

I have another Windows-based program which can do such encoding and which is very fast, but it requires to manually open an uncompressed file ("browse") and choose a "save as" file and clicking the "start" button. And, once the encoding is finished for the current file, these steps must be repeated again for the next file, and the next, and the next one. Do you have any idea how this process can be automated to batch process all files in a folder? Can you point me to any direction to solve this puzzle?
 

My Computer My Computer

Computer type
PC/Desktop
OS
Win7 Ultimate 64 bit
The bat script you suggested does indeed work, thank you very much for it, the problem is that this encoder has turned out to be so slow, it is unusable for any practical purpose.
I had a feeling.

I have another Windows-based program which can do such encoding and which is very fast, but it requires to manually open an uncompressed file ("browse") and choose a "save as" file and clicking the "start" button. And, once the encoding is finished for the current file, these steps must be repeated again for the next file, and the next, and the next one. Do you have any idea how this process can be automated to batch process all files in a folder? Can you point me to any direction to solve this puzzle?
Batch files cannot be used to interact with GUI elements. You'll need to consult this program's documentation and find out if it has a command-line interface. If so, please post here a demonstration of a single working command-line snippet of the program in action, as you've done in post one. And after that, making the batch file is the easy part.
 

My Computer My Computer

Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Back
Top