//删除该目录的所有子目录中的“作品”两个字
import java.io.File object Dir { def main(args: Array[String]): Unit = { val file = new File("F:\※\文档/") val files = file.listFiles() files.foreach(f=>{ val isDirectory = f.isDirectory val name = f.getName //println(name) if (name.contains("作品")&&isDirectory){ val i = name.indexOf("作品") println(name+"===>"+i+"==>"+name.substring(0,i)+name.substring(i+2,name.length)) f.renameTo(new File("F:\※\文档/"+name.substring(0,i)+name.substring(i+2,name.length))) } }) print("wancheng") } }