Posts

Showing posts from April, 2019

Remove specific characters from file name if exists

There was many songs with the name of websites from which they were downloaded. i wanted to remove the name of websites from the name of song. Just for cleanness of name appearances in music player. I made java program for that. import java.io.File; public class StringRepeat { static File f[] = new File("c:/users/thesa/desktop/new folder/").listFiles(); static String str[] = new String[f.length]; public static void main(String agrs[]) { for (int i = 0; i < f.length; i++) { str[i] = (f[i].getName()); StringBuffer sb = new StringBuffer(str[i]); int x = (sb.lastIndexOf("www.djmaza.com")); if (x > 0) { System.out.println("File before renaming " + sb); sb.delete(x, x + 3); System.out.println("File after renaming " + sb); System.out.println("result from getparent " + f[i].getParent()); System.out.println("For loop end"); File renamed = new File(f[i].getParent() + ...