我想:
find /dir -type f
/dir/2008/12/10/21_13_026.jpg
/dir/2008/09/16/01_53_012.jpg
/dir/2008/09/16/01_52_011.jpg
/dir/2008/09/16/01_54_013.jpg
/dir/2008/09/16/01_56_015.jpg
/dir/2008/09/16/01_58_016.jpg
/dir/2008/09/16/01_55_014.jpg
/dir/2008/09/16/01_51_010.jpg
/dir/2008/09/09/17_17_008.jpg
/dir/2008/09/25/17_02_001.jpg
/dir/2008/09/25/18_35_002.jpg
/dir/2008/09/15/22_59_005.jpg
/dir/2008/09/15/22_57_007.jpg
/dir/2008/09/15/22_56_009.jpg
/dir/2008/09/15/22_58_006.jpg
/dir/2008/09/15/23_02_003.jpg
/dir/2008/09/15/22_53_008.jpg
/dir/2008/09/15/23_00_004.jpg
/dir/2008/09/01/18_50_013.jpg
然后将每个文件重命名为输出它在查找结果中的相应行,但将/替换为 -
类似的东西:
find /dir -type f -exec rename {} sed -i 's/\//-/g' \;
重点是从
重命名每个文件/dir/2008/09/15/23_00_004.jpg
到
-dir-2008-09-15-23_00_004.jpg
但是我的语法和重命名执行不对。有什么建议吗?
感谢
答案 0 :(得分:0)
试试这个:
find /dir -type f -exec rename 's|/|-|g' {} \;