Solved

How Can I Rename mp3 files easily-special situation

Posted on 2016-10-22
17
54 Views
Last Modified: 2016-10-27
This is round 2 for a question I've asked earlier, but this time with a better example and clearer explanation of what is needed.

The object is to find a fast and easy way to reformat the names of mp3 files. PLEASE NOTE that I am not a code writer, so any responses about me writing code will be worthless.

Let's say I have this list of files:

TaxHelp.mp3
WeightLoss.mp3
HealthMarkets.mp3
LasikVision.mp3
LifeInsurance.mp3
SandalsResorts.mp3

I need to change their names to:

1.1-Spot1.mp3
1.2-Spot2.mp3
2.1-Spot1.mp3
2.2-Spot2.mp3
3.1-Spot1.mp3
3.2-Spot2.mp3

So, the first thing I need is some simple way to do this quickly and easily. If the solution is a piece of software, please make sure you have run this project through the software yourself and not just looked it over.

Now, the second thing I need is for the solution to be flexible enough so that a week later (and each week after that), the same re-naming can be done quickly and easily--BUT with the file names  In different order.

Example:

Week One Files                  Renamed As

TaxHelp.mp3                      1.1-Spot1.mp3
WeightLoss.mp3                1.2-Spot1.mp3
HealthMarkets.mp3          2.1-Spot1.mp3
LasikVision.mp3                 2.2-Spot1.mp3
LifeInsurance.mp3             3.1-Spot1.mp3
SandalsResorts.mp3          3.2-Spot1.mp3

Week Two Files                  Renamed As

LifeInsurance.mp3                 1.1-Spot1.mp3
WeightLoss.mp3                    1.2-Spot2.mp3
LasikVision.mp3                     2.1-Spot1.mp3
HealthMarkets.mp3              2.2-Spot2.mp3
SandalsResorts.mp3             3.1-Spot1.mp3
TaxHelp.mp3                         3.2-Spot2.mp3

I need to do this weekly for about 50-60 different files, and really need to find a way to get the reaming done faster than doing it individually, even by using a simple macro, which still requires file-by-file work rather than getting it done for all the files in one batch quickly.

Suggestions/solutions?
0
Comment
Question by:RadioGeorge
  • 11
  • 6
17 Comments
 
LVL 5

Expert Comment

by:Austin Texas
ID: 41855726
There are a lot of bulk file renaming utilities out there. For someone to recommend one to you , it would help to know things like your OS (some utilities do not run on some OS versions) and the file structure (are each of these weekly batches of files in different directories or are they all in the same directory?

But the biggest question I have is, how are you determining which file to rename to which new name. What I mean is, are you just renaming files indiscriminately or is there some logic behind why TaxHelp.mp3 and WeightLoss.mp3 should be spots 1.1 and 1.2 while HealthMarkets.mp3 and LasikVision.mp3  become spots 2.1 and 2.2? In the example, files are not in alphanumerical order, so should I assume that you will need a way to define which files get renamed to what?

Thanks for any additional explanation you can provide.
0
 
LVL 5

Expert Comment

by:Austin Texas
ID: 41855751
Here is a simple batch script that will change all the *.mp3 files to the format you specified:

set /a a=1
set /a b=1
setlocal ENABLEDELAYEDEXPANSION
for /f "tokens=*" %%f in ('dir /b *.mp3') do (
  ren %%f !a!.!b!-Spot!b!.mp3
  if "!b!" EQU "1" (
    set /a b=2
  ) else (
    set /a a+=1
    set /a b=1
  )
)

Open in new window

See if that will work for you.
0
 

Author Comment

by:RadioGeorge
ID: 41855971
on the road and will check the script later in the day. To answer your questions:

--running on Windows 10 and would also hope that it will run on Windows 7 and/or XP. I use backup computers (XP offline, of course) from time to time but 10 is the main one.

The renaming of the files: these are in fact commercials and the sequence is shuffled depending on:
--cancellations of expired ones
--new ones being added to the lineup
--requests for heavier exposure for some for short periods of time
--personal judgment as to whether or not some need to be run in ceratin hours more heavily than other hours

So this is a situation that is handled individually every week. It is easy to simply make the hourly lists, but not so easy when you have to rename them all with the numbering system, which is used by the players that play the mp3 files.
0
 
LVL 5

Expert Comment

by:Austin Texas
ID: 41856172
So if the numbering is needs to be defined by someone, then we need a way to get that information into the routine. You could have someone write and interface but I think that would be overkill. I am guessing that because we are looking for a way to automate this renaming that you don't expect them for whatever reason to rename them to your naming convention. Would it be possible to have the person who chooses the order of the spots to at least rename them with a leading number? For example:

Week One Files                  Renamed As
-------------------------              ---------------------------
TaxHelp.mp3                      1-TaxHelp.mp3
WeightLoss.mp3                2-WeightLoss.mp3
HealthMarkets.mp3          3-HealthMarkets.mp3
LasikVision.mp3                 4-LasikVision.mp3
LifeInsurance.mp3             5-LifeInsurance.mp3
SandalsResorts.mp3          6-SandalsResorts.mp3

This way the files would be sorted correctly and then could be renamed by the script correctly.

If we need a way for someone to input the numbers for the files as the script is running, that will require a different script.
0
 
LVL 5

Expert Comment

by:Austin Texas
ID: 41856235
This is an example of a script that asks for input to rename each file.

@echo off
setlocal EnableDelayedExpansion
echo Please enter the number of the break and the 
echo order in the break for the following spots:
for /f "tokens=*" %%f in ('dir /b *.mp3') do (
  echo -- Break and play order for %%f
  set /p a="Which break? "
  set /p b="Play order? "
  ren %%f !a!.!b!-Spot!b!.mp3
)

Open in new window

0
 
LVL 5

Expert Comment

by:Austin Texas
ID: 41856241
By the way, I did test these sample scripts in Win10 and they work.
0
 

Author Comment

by:RadioGeorge
ID: 41856387
Austin, first, thanks for the time and effort you are putting into this question.

The numbering convention I used in my example,
1.1-Spot1.mp3
1.2-Spot2.mp3
2.1-Spot1.mp3
2.2-Spot2.mp3
3.1-Spot1.mp3
3.2-Spot2.mp3

is that way for a specific reason: the player that plays the mp3 files was modified to play files in sequential order. So what we have is show segments and commercial ("spot") segments in an overall file that looks like this:

1-Austin Show Segment 1.mp3
1.1-Spot1.mp3
1.2-Spot2.mp3
2-Austin Show Segment 2.mp3
2.1-Spot1.mp3
2.2-Spot2.mp3
3-Austin Show Segment 3.mp3
3.1-Spot1.mp3
3.2-Spot2.mp3

and so up for a total of show segments ranging from 7 to 12 for various shows.

FYI, the show segments do not come neatly numbered, of course, but using Free Commander software, it is super fast and simple to change the segment names as shown in the example here with just a couple of clicks, once you have set up the naming format. I have tried to do the same thing for the spot files, but it sure looks like Free Commander can't do that because of the odd and non-perfectly-consecutive numbering the spots use.
0
 
LVL 5

Expert Comment

by:Austin Texas
ID: 41856429
I imagined something like what you described was the case.

So you now have two scripts that will give you two options of how to proceed. Let me know if you are now good to go!
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:RadioGeorge
ID: 41857907
Austin, this may sound like a dumb question, but I have to ask: what program  do I use to run those scripts you sent? I am simply not familiar with running scripts like this, so I need some very basic information.  Can't start the car unless you know where to put the key!
0
 
LVL 5

Expert Comment

by:Austin Texas
ID: 41858036
1. open notepad and paste the script in.
2. save it somewhere with whatever name you prefer but with the extension .bat
3. stick that file in the directory that you are going to do some renaming.
4. double-click on it.

That should do it. Hit f5 when you are looking at the directory to refresh if the files do not appear to have changed.

Let me know if you have any other questions.
0
 

Author Comment

by:RadioGeorge
ID: 41859682
Austin,  tried the second one as per your instructions today and it seemed to work just fine. I will do it again tomorrow and test the first one and then report back and wrap it up. Naturally, you'll get all the points for your great help. Wonder if this will lead me to come up with some more things to hit you up with??
0
 
LVL 5

Expert Comment

by:Austin Texas
ID: 41859821
Remember, those scripts do different things. The first renames them all in a single sweep by whatever alphanumeric order they fall into, while the second is interactive. I recommend testing them with files that you have backup copies of.
0
 

Author Comment

by:RadioGeorge
ID: 41862762
Austin, I have tried the second script several times several times (in Windows 7) and now, no matter what numbers I enter, I am getting an error message:

screenshot of bat file
Am I doing something wrong?
0
 
LVL 5

Accepted Solution

by:
Austin Texas earned 500 total points
ID: 41863185
...And that is why we have to test stuff in a real environment. I suspect the problem is spaces in the file names. (please confirm)

In my testing (and in your example files) there were not spaces in the file names.  There is a small edit in both scripts that will allow them to handle files a little better like that.

Try these:

set /a a=1
set /a b=1
setlocal ENABLEDELAYEDEXPANSION
for /f "tokens=*" %%f in ('dir /b *.mp3') do (
  ren "%%f" !a!.!b!-Spot!b!.mp3
  if "!b!" EQU "1" (
    set /a b=2
  ) else (
    set /a a+=1
    set /a b=1
  )
)

Open in new window


@echo off
setlocal EnableDelayedExpansion
echo Please enter the number of the break and the 
echo order in the break for the following spots:
for /f "tokens=*" %%f in ('dir /b *.mp3') do (
  echo -- Break and play order for %%f
  set /p a="Which break? "
  set /p b="Play order? "
  ren "%%f" !a!.!b!-Spot!b!.mp3
)

Open in new window

0
 

Author Comment

by:RadioGeorge
ID: 41863270
Ah, the wonders of code testing! Austin, you fixed the spaces-between-names problem perfectly. Both  scripts work 100% as they should. The second one is the one that will likely get used the most. A real timesaver. You are most definitely DA MAN. Thank you, Thank You, Thank You.
0
 
LVL 5

Expert Comment

by:Austin Texas
ID: 41863321
I'm glad I could help. Please don't forget to mark whose answer helped you so that we get our points. I have had an account here for a long time but have just become active this month so I have a lot of catching up to do get my points to a respectable level.

Also, if you or anyone you know needs any work for hire done, let me know! I am currently between jobs and looking for work.

Thanks!
0
 
LVL 5

Expert Comment

by:Austin Texas
ID: 41863324
I just now see that you accepted my solution!  Thanks for the points!
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

First of all what is the DMCA? The DMCA is a set of laws first enacted in 1998. The Act was modified on 2000, and again on 2001, 2004, and 2007. Its goal was to update the Copyright act of 1973 for the digital age. In a world with MP3 playing cap…
Are you looking to clear some space on your phone for the latest iOS 8 update? Did you switch to Spotify so you no longer need to keep music native on your phone? Run out of space for taking photos while in the middle of vacation? Sometimes the quic…
Viewers will learn how to create and use Simpler instruments in Ableton Live. Load new Simpler into an empty MIDI track: Select a sample and drop it into sample window in Simpler: If sample is not pitched at C3, adjust tuning with Transpose para…
Viewers will learn how to use LFOs to modulate the sound of their Sampler instruments. Click the Modulation tab in Sampler: Choose one (or more) of the three available LFOs, and click the respective button to turn it on: Select a waveform, an LF…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now