Tuesday, 5 November 2013

File Extension change

hi,


here i am going to write you how to change file extension of a folder.

Just copy and paste


import java.io.BufferedReader;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;


public class ToChanegExtension
{

public static void main(String[] args)
{
File  path=new File("G:/songs/new");  //just copy paste the path here
File[] listOfFiles = path.listFiles();
try{
for(File file : listOfFiles) {
String name=file.getName();
if(name.matches(".*\\.jpg"))
{
String newName[]=name.split(".jpg");
File newF=new File("G:/songs/new/"+newName[0]+".mp3");

file.renameTo(newF);
}
}
}
catch(Exception e)
{
System.out.println("In catch");
}
}

}




No comments:

Post a Comment