Index: /trunk/src/org/openstreetmap/josm/plugins/PluginDownloader.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/plugins/PluginDownloader.java	(revision 2553)
+++ /trunk/src/org/openstreetmap/josm/plugins/PluginDownloader.java	(revision 2554)
@@ -106,7 +106,8 @@
     public static int downloadDescription() {
         int count = 0;
+        LinkedList<String> sitenames = new LinkedList<String>();
         for (String site : getSites()) {
-            /* TODO: remove old site files (everything except .jar) */
             try {
+                String filesite = site.replaceAll("%<(.*)>", "");
                 /* replace %<x> with empty string or x=plugins (separated with comma) */
                 String pl = Main.pref.getCollectionAsString("plugins");
@@ -114,10 +115,11 @@
                     site = site.replaceAll("%<(.*)>", "$1"+pl);
                 else
-                    site = site.replaceAll("%<(.*)>", "");
+                    site = filesite;
                 BufferedReader r = new BufferedReader(new InputStreamReader(new URL(site).openStream(), "utf-8"));
                 new File(Main.pref.getPreferencesDir()+"plugins").mkdir();
+                String sname = count + "-site-" + filesite.replaceAll("[/:\\\\ <>|]", "_") + ".txt";
+                sitenames.add(sname);
                 BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
-                        new FileOutputStream(new File(Main.pref.getPluginsDirFile(),
-                                count + "-site-" + site.replaceAll("[/:\\\\ <>|]", "_") + ".txt")), "utf-8"));
+                        new FileOutputStream(new File(Main.pref.getPluginsDirFile(), sname)), "utf-8"));
                 for (String line = r.readLine(); line != null; line = r.readLine()) {
                     out.append(line+"\n");
@@ -127,4 +129,28 @@
                 count++;
             } catch (IOException x) {
+            }
+        }
+        /* remove old files */
+        File[] pluginFiles = Main.pref.getPluginsDirFile().listFiles();
+        if (pluginFiles != null) {
+            for (File f : pluginFiles) {
+                if (!f.isFile())
+                    continue;
+                String fname = f.getName();
+                if(fname.endsWith(".jar"))
+                {
+                    for(String s : PluginHandler.oldplugins)
+                    {
+                        if(fname.equals(s+".jar"))
+                        {
+                            System.out.println(tr("Delete old plugin {0}",fname));
+                            f.delete();
+                        }
+                    }
+                }
+                else if(!fname.endsWith(".jar.new") && !sitenames.contains(fname))
+                {
+                    System.out.println(tr("Delete old plugin file {0}",fname));
+                }
             }
         }
Index: /trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java	(revision 2553)
+++ /trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java	(revision 2554)
@@ -42,4 +42,10 @@
 public class PluginHandler {
 
+    public static String [] oldplugins = new String[] {"mappaint", "unglueplugin",
+                "lang-de", "lang-en_GB", "lang-fr", "lang-it", "lang-pl", "lang-ro",
+                "lang-ru", "ewmsplugin", "ywms", "tways-0.2", "geotagged", "landsat",
+                "namefinder", "waypoints", "slippy_map_chooser", "tcx-support", "usertools"};
+    public static String [] unmaintained = new String[] {"gpsbabelgui", "Intersect_way"};
+
     /**
      * All installed and loaded plugins (resp. their main classes)
@@ -59,10 +65,4 @@
             plugins.addAll(Arrays.asList(System.getProperty("josm.plugins").split(",")));
         }
-
-        String [] oldplugins = new String[] {"mappaint", "unglueplugin",
-                "lang-de", "lang-en_GB", "lang-fr", "lang-it", "lang-pl", "lang-ro",
-                "lang-ru", "ewmsplugin", "ywms", "tways-0.2", "geotagged", "landsat",
-                "namefinder", "waypoints", "slippy_map_chooser", "tcx-support", "usertools"};
-        String [] unmaintained = new String[] {"gpsbabelgui", "Intersect_way"};
 
         for (String p : oldplugins) {
