Tips

This page contains some sample programs which helped me during my career

This application will help you find all the files in a folder and if will change all the filenames etc.
               import java.io.File;

public class RenameFiles 
{
 
 public static void main(String[] args) 
{
 
  String path = "C:/Users/abcs/"; 
 
  String oldFilename;
  File folder = new File(path);
  File[] listOfFiles = folder.listFiles(); 
  File oldfile = null;
	File newfile = null;
  for (int i = 0; i < listOfFiles.length; i++) 
  {
 
   if (listOfFiles[i].isFile()) 
   {
   oldFilename = listOfFiles[i].getName();
   oldfile =new File(path+"/"+oldFilename);
   newfile =new File(path+"/newfilename"+i+".jar");

	if(oldfile.renameTo(newfile)){
		System.out.println("Rename succesful");
	}else{
		System.out.println("Rename failed");
	}

      }
   
  
  }
}
}
         
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s