How to rename with prefix/suffix?

You could use the rename(1) command: rename ‘s/(.*)$/new.$1/’ original.filename Edit: If rename isn’t available and you have to rename more than one file, shell scripting can really be short and simple for this. For example, to rename all *.jpg to prefix_*.jpg in the current directory: for filename in *.jpg; do mv “$filename” “prefix_${filename}”; done; or … Read more

Python regex – r prefix

Because \ begin escape sequences only when they are valid escape sequences. >>> ‘\n’ ‘\n’ >>> r’\n’ ‘\\n’ >>> print ‘\n’ >>> print r’\n’ \n >>> ‘\s’ ‘\\s’ >>> r’\s’ ‘\\s’ >>> print ‘\s’ \s >>> print r’\s’ \s Unless an ‘r’ or ‘R’ prefix is present, escape sequences in strings are interpreted according to … Read more