Renaming multiple files by adding a string to the beginning

  • rename 's/^/1_/' * for renaming all files in the current directory

or

  • rename 's/^/1_/' DATASET* for renaming all files in the current directory starting with DATASET in their name

Explanation: the expression s/^/1_/ says: "replace the beginning of the filename (that means this symbol -> ^)' with 1_".


You can easily rename all the files in current directory typing (assuming you are using bash):

for i in *; do mv "$i" 1_"$i"; done

obviously take it with care; it will remane ALL the files in the current directory that are 'visible' (filename not starting with a '.')


You can use pyRenamer. It can be found in the Ubuntu software center. enter image description here The original file pattern should be {X} and the renamed file pattern should be 1_{1}