Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do multiple things to each file in a directory with a batch script

This is a direct extension of this question:

How to do something to each file in a directory with a batch script

From the above I leaned how to execute a command for every file in a folder.

How do you execute MULTIPLE commands for each file? I want to first use lame to compress the file, then MOVE the original file to a different directory

This is what I have so far:

FOR /r cutAndPendingCompression %%f IN (*.*) DO lame %%f compressed\%%~nf -m m -b 16 --vbr-new -V 9 --scale 2.5
like image 267
Jonah Avatar asked Feb 21 '10 05:02

Jonah


People also ask

How do you sequentially execute commands in batch file?

Instead of scheduling multiple Windows Tasks that may overlap, use the "start /wait" command a batch file (. bat) to automatically run multiple commands in sequential order.

What does %% do in batch?

Use double percent signs ( %% ) to carry out the for command within a batch file. Variables are case sensitive, and they must be represented with an alphabetical value such as %a, %b, or %c. Required. Specifies one or more files, directories, or text strings, or a range of values on which to run the command.

Can a batch script file run multiple commands at the same time?

You can run two commands in one line in Windows Command Prompt. For that, you need to create a batch script file using Notepad. Below, we have shared the two best methods to run multiple commands in CMD on Windows 10 computers.


1 Answers

This did it

FOR /r cutAndPendingCompression %%f IN (*.*) DO (
lame %%f compressed\%%~nf -m m -b 16 --vbr-new -V 9 --scale 2.5
move %%f cut\%%~nf
)
like image 184
Jonah Avatar answered Oct 19 '22 02:10

Jonah