我正在寻找一种方法来根据下面提到的标准对一堆文件进行批重命名:
文件列表与此类似,应该是字母数字:
下面的伪代码与我希望它的行为方式非常接近,但我正在尝试确定sed、awk、python、perl或bash脚本是正确的方法(我正在检查选项,以确定我可能需要深入研究的实现):
for all_files_in_dir:{
if(currentfile.name is_close_to previousfile.name){ //maybe regex here
var small_file = find_smaller_file_filename(currentfile.filesize, previousfile.filesize);
sys.remove(small_file);
}
}
谢谢你的建议!在
我将用Perl发布一个解决方案,只是因为您没有考虑到它的可能性:)
以及python中的另一个解决方案:
^{pr2}$请注意,您需要对文件进行排序,因为glob不会按字典顺序返回它们
我想这应该行得通。在
^{pr2}$我的词条:不那么简洁,但希望可读。在
相关问题 更多 >
编程相关推荐