我正在编写一个小程序来获取我的音乐文件的订单(使用Win8)。我使用的其中一个类在需要时将填充轨道号的文件重命名为零。该脚本用于更改名称,但不会重命名该文件。它不会抛出错误,只是不重命名文件。
无效的位:
String newTrackkName = item.replace(oldFileName, newFileName);
File oldFile = new File(oldFileName);
Boolean renamed = oldFile.renameTo(new File(newFileName));
System.out.println("\nthe file '" + item + "'" + ((!renamed) ? "\n\tHas NOT been renamed '" : "\n\tHas been renamed '") + newTrackkName + "'");
以下是println输出的示例:
the file 'c:\test\Al Green\Compact Command Performances_ 14 Greatest Hits\14 - Livin For You.mp3'
Has NOT been renamed 'c:\test\Al Green\Compact Command Performances_ 14 Greatest Hits\14 - Livin For You.mp3'
the file 'c:\test\Al Green\Compact Command Performances_ 14 Greatest Hits\2 - Call Me (Come Back Home).mp3'
Has NOT been renamed 'c:\test\Al Green\Compact Command Performances_ 14 Greatest Hits\02 - Call Me (Come Back Home).mp3'
the file 'c:\test\Al Green\Compact Command Performances_ 14 Greatest Hits\3 - I'm Still In Love With You.mp3'
Has NOT been renamed 'c:\test\Al Green\Compact Command Performances_ 14 Greatest Hits\03 - I'm Still In Love With You.mp3'
the file 'c:\test\Al Green\Compact Command Performances_ 14 Greatest Hits\4 - Here I Am (Come And Take Me).mp3'
Has NOT been renamed 'c:\test\Al Green\Compact Command Performances_ 14 Greatest Hits\04 - Here I Am (Come And Take Me).mp3'
the file 'c:\test\Al Green\Compact Command Performances_ 14 Greatest Hits\5 - How Can You Mend A Broken Heart.mp3'
Has NOT been renamed 'c:\test\Al Green\Compact Command Performances_ 14 Greatest Hits\05 - How Can You Mend A Broken Heart.mp3'
至少我不会对重命名说谎: - )。
任何好的建议,我都尝试使用Files.move选项,但也没有用。