Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need help writing a script/batch file

Posted on 2014-03-04
12
Medium Priority
?
1,081 Views
Last Modified: 2014-03-05
I have a list of files that correspond to files I need to run a script against.

The list looks like this:
1111
2222
3333
4444
5555
etc...all the values are numerical.

These go to a bunch of files in 'pairs' with -in and -out at the end of the 1111,2222,etc.

I want to write a script that will take that list, pass it to a command
sox -m %1-in.wav %1-out.wav %1.wav

So it would run
sox -m 1111-in.wav 1111-out.wav 1111.wav
then
sox -m 2222-in.wav 2222-out.wav 2222.wav
Until it reaches the end of the list.

I don't know scripting, but I am sure this might be easy to someone who does.
0
Comment
Question by:mvalpreda
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
12 Comments
 
LVL 57

Expert Comment

by:Bill Prew
ID: 39905303
This should do what you asked:

@echo off
setlocal

set List=1111,2222,3333,4444,5555,6666

for %%A in (%List%) do (
  sox -m %%A-in.wav %%A-out.wav %%A.wav
)

Open in new window

~bp
0
 
LVL 2

Author Comment

by:mvalpreda
ID: 39905348
Can I set that list to a file with that info?

I have 30,000 of those entries per directory and probably 40 directories.
0
 
LVL 57

Accepted Solution

by:
Bill Prew earned 2000 total points
ID: 39905372
Yes, here is an example of reading the file names from a text file.

If you wanted to automate that further you could have one file that lists the directories to process, and then in each file read the list file to process the individual files.  Of course the list files in each folder would need to have the same name.

@echo off
setlocal

set ListFile=c:\temp\list.txt

for /f "usebackq tokens=1" %%A in ("%ListFile%") do (
  sox -m %%A-in.wav %%A-out.wav %%A.wav
)

Open in new window

~bp
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 2

Author Comment

by:mvalpreda
ID: 39905380
I was going to do a dir /b and dump that to a text file and clean it up without the -in and -out files. If there is a way to automate that, I am all for it. :)
0
 
LVL 57

Expert Comment

by:Bill Prew
ID: 39905404
I'm sure we can take a lot of the work out of this.  I just need to understand the situation a bit more.

Can you describe the folders and files that need to be processed a bit more?  Like, is there one master "base folder", and then one level down of subfolders that contain the files?  And do all subfolders in the base need to be processed, or only a selection of them that you need to specify?

Do all the files in each folder need to be processed, or only a subset that you need to specify?

Any thing else that might help?

We might be able to do this with no text files depending on the specifics...

~bp
0
 
LVL 2

Author Comment

by:mvalpreda
ID: 39905459
Bunch of folders organized by date. Structure looks like z:\2014\03\04\monitor\ for today. Yesterday would have been z:\2014\03\03\monitor\.

I don't mind running it on each directory as there is only about 30-40 directories that need this done. It is not going to be an ongoing thing, just a bit of a programming glitch that went unchecked for about two months.
0
 
LVL 57

Expert Comment

by:Bill Prew
ID: 39906262
Okay, so will all files in each folder need to be processed?

And, can the "sox" utility take a full path to the files involved?

~bp
0
 
LVL 2

Author Closing Comment

by:mvalpreda
ID: 39908060
Just what I needed. Did a little extra work by dumping the directory to a text file and then feeding that file into the little script you wrote.

Programmer has fixed their issue....but I have this just in case. I know it will come in handy again in the future.

Thanks again.
0
 
LVL 57

Expert Comment

by:Bill Prew
ID: 39908130
Welcome, glad that was helpful.

~bp
0
 
LVL 2

Author Comment

by:mvalpreda
ID: 39908133
Only thing I changed was removing '@echo off' so I could see how far along it is. A blank screen can be a tad scary. :)
0
 
LVL 57

Expert Comment

by:Bill Prew
ID: 39908140
Understand, depending on the script @echo off can be a good or bad thing.  I often add some ECHO lines in the script to display status info along the way to help keep updated on progress.  But for small ones just removing the @echo off can get the job done.

~bp
0
 
LVL 57

Expert Comment

by:Bill Prew
ID: 39908141
And by the way, thanks for helping push me over the 1,000,000 mark in Windows Batch Scripting!

~bp
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question