Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Please help me make bat file to process all files in a folder

18 Feb 2015   #1
ironmine

Win7 Ultimate 64 bit
 
 
Please help me make bat file to process all files in a folder

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 System SpecsSystem Spec
.
19 Feb 2015   #2
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

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 System SpecsSystem Spec
19 Feb 2015   #3
ironmine

Win7 Ultimate 64 bit
 
 

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 System SpecsSystem Spec
.

19 Feb 2015   #4
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

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 System SpecsSystem Spec
19 Feb 2015   #5
ironmine

Win7 Ultimate 64 bit
 
 

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 System SpecsSystem Spec
19 Feb 2015   #6
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

Quote   Quote: Originally Posted by ironmine View Post
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.

Quote   Quote: Originally Posted by ironmine View Post
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 System SpecsSystem Spec
Reply

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




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
NSIS error writing temporary file. make sure your temp folder is valid
I've had this problem going on for 5 months now , every now and then i get this error , i have 2 drivers on my pc , one ssd for OS and some programs and an HDD for games and mass storage. I get this whenever i try to run a setup from inside the downloads folder located on the HDD , the D disc....
Software
How to make File Explorer display full address of files in search
I have done a search and file explorer returns some results. You can see the locations of each file are chopped off. But there is no grid splitter allowing me to expand the filename column. How can I view the whole address of the files in Search results?
General Discussion
How to use 2 bin files (“boot extract”) to make a bootable iso file?
How to use 2 bin files (“boot extract”) to make a bootable iso file? I want to make a bootable iso file of myWindows 7 Ultimate DVD (64 bits) in order to use on a bootable USB drive and to use for re-installation. Bart's Boot Image Extractor (bbie.exe) gives 2 bin files of 2 sectors...
Performance & Maintenance
adding a file make folder show to how to stop that
i am new to windows 7 and trying to "learn" it...i save and write lots of word files, document files etc...each time i write/save a file, it shows its folder to. I need to know how to just show the file i did. other windows didn't do this. I know you can make folders to hold your files. any help...
Customization
How to make ISO file out of Windows 7 files
I have recently purchased VAIO notebook that comes with windows7 sp1 but without installation disc. I was told I just need to create system image later on a DVD which I can use for any restoration or reinstallation purpose in the event of any crash/virus attack. Product key anyway is specified on...
Backup and Restore
Batch file for moving files to folder?
Hello, Wanted to see if any one here wouldn't mind writing a batch file or script that would move multiple files to a target folder. Here are the specifics: HDD1 Contains Folders A,B,C,etc... Folder A contains Folder A1 which contains File A2 Folder B contains Folder B1 which contains File B2...
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd

All times are GMT -5. The time now is 00:21.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App