1
package common;
2
3
import java.io.File;
4
import java.io.IOException;
5
6
public class RenameFile
{
7
public static void main(String[] args) throws IOException
{
8
String folder = "G:\\shopdata\\\\userdata_bak\\";
9
renameFileName(new File(folder));
10
System.out.println("over");
11
}
12
13
private static void renameFileName(File folder) throws IOException
{
14
System.out.println("folder: "+ folder);
15
File[] files = folder.listFiles();
16
for (int i = 0; i < files.length; i++)
{
17
File file = files[i];
18
if (file.isDirectory())
{
19
renameFileName(file);
20
} else
{
21
String oldName=file.getCanonicalPath();
22
if (oldName.endsWith("html"))
{
23
return;
24
}
25
File newName = new File(oldName.replace("aspx", "html"));
26
boolean bool=file.renameTo(newName);
27
//System.out.println(bool +" : "+newName);
28
}
29
}
30
31
}
32
}
33
34

2

3

4

5

6



7



8

9

10

11

12

13



14

15

16



17

18



19

20



21

22



23

24

25

26

27

28

29

30

31

32

33

34
