scan directory and rename


/ Published in: Java
Save to your folder(s)



Copy this code and paste it in your HTML
  1. import java.io.File;
  2. import java.net.URI;
  3. import java.net.URISyntaxException;
  4. import java.util.*;
  5.  
  6. public class GETFILE{
  7. public static void main(String[] vargs){
  8. File aFile = new File(vargs[0]);
  9. File[] files = aFile.listFiles();
  10. ArrayList<File> fileList = new ArrayList<File>();
  11. scan(aFile, fileList);
  12.  
  13. for(File f: fileList) {
  14. System.out.println(f.toString());
  15. f.renameTo(new File("plugin.zip"));
  16. }
  17.  
  18. }//end main
  19.  
  20. private static void scan(File file, ArrayList<File> all){
  21. File[] files = file.listFiles();
  22. if (files != null) {
  23. for (File child : files) {
  24. if(child.isDirectory()){
  25. scan(child, all);
  26. }else{
  27. all.add(child);
  28. }
  29. }
  30. }
  31. }
  32.  
  33. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.