Skip to main content

Posts

Showing posts with the label rename. files

Day-to-day Programming 3: Rename Files with numbers - part 2

How to rename bunch of files with numbers (with leading zeros)? I mentioned in my earlier post  Day-today Programming 2     about the simple java program to rename files with numbers.  eg:- 1.MP3 2.MP3 3.MP3  ... As I said there were about 200 MP3s. Mom wanted them to play in the numbered order. But when the DVD player plays them after playing 1.MP3 it didn't play 2.MP3 next. It played 10.MP3 instead. That was because it plays them in ascending order.  When it plays in ascending order, after 1, the next one is 10, and the next one is 100. It plays 2.Mp3 after finishing all the tracks that start from digit 1. So I had to write the DVD again. This time I have to rename them in a different way.  If I rename them with leading zeros, it will play them in the order as numbered. eg:- 001.MP3 002.MP3 ... 010.MP3 ... 100.MP3 In order to do that, I changed my previous renaming program a little bit. This might not be the most efficient way...

Day-to-day Programming 2: Rename Files with numbers

How to rename a bunch of files with numbers? From my earlier post-Day-today  Programming 1  I told you how my mom asked me to write her a DVD. Then as I mentioned earlier, I managed to take a printout of the filenames. Now I have to write them into a DVD. But mom asked me to rename the MP3s with numbers. so that she can find the number of the MP3 printed-out document. So I again wrote a simple java program to rename the files with numbers starting from 1. Here is the small program I wrote. //simple java program to rename files with numbers.  import java.io.File; import java.io.IOException; public class Rename2Numbers { public static void main(String[] args) throws IOException { File folder = new File("C:/My Folder"); int i = 1; for(File f : folder.listFiles()){ f.renameTo(new File("C:/My Folder/"+i+".mp3")); i++; } ...