Rename Files and Directories (Add Prefix)

后端 未结 10 1078
谎友^
谎友^ 2020-12-22 14:54

I would like to add prefix on all folders and directories.

Example:

I have

Hi.jpg
1.txt
folder/
this.file_is.here.png
another_folder.ok/
         


        
10条回答
  •  醉梦人生
    2020-12-22 15:18

    To add a prefix to all files and folders in the current directory using util-linux's rename (as opposed to prename, the perl variant from Debian and certain other systems), you can do:

    rename ''  *
    

    This finds the first occurrence of the empty string (which is found immediately) and then replaces that occurrence with your prefix, then glues on the rest of the file name to the end of that. Done.

    For suffixes, you need to use the perl version or use find.

提交回复
热议问题