{"authors":["utzer"],"canonical_url":"https://newblog.utzer.de/2019/04/29/rename/","categories":["Linux"],"content":"... is an easy to use and powerful tool, it can be used to replace part of file name (string1) with some other string. Something one can also do with some \"sed\" hack, but this tool is much easier to use, especially for beginners.\n\nYou can get all information needed from \"rename --help\" (here from Linux Mint):\n\n```\nrename --help\nUsage:\n    rename [ -h|-m|-V ] [ -v ] [ -n ] [ -f ] [ -e|-E perlexpr]*|perlexpr\n    [ files ]\n\nOptions:\n    -v, -verbose\n            Verbose: print names of files successfully renamed.\n\n    -n, -nono\n            No action: print names of files to be renamed, but don't rename.\n\n    -f, -force\n            Over write: allow existing files to be over-written.\n\n    -h, -help\n            Help: print SYNOPSIS and OPTIONS.\n\n    -m, -man\n            Manual: print manual page.\n\n    -V, -version\n            Version: show version number.\n\n    -e      Expression: code to act on files name.\n\n            May be repeated to build up code (like \"perl -e\"). If no -e, the\n            first argument is used as code.\n\n    -E      Statement: code to act on files name, as -e but terminated by\n            ';'.\n```\n\nI did use this tool rename some files that contained the string \"www\", which I had to replace with \"web\", lets say there were files named like this:\n\nwww.example.com-97126.ccd  \nwww.example.com-54852.ccd  \nwww.example.com-87430.ccd  \nwww.example.com-75413.ccd\n\nFor Ubuntu, maybe also Debian, based systems I use the following command to rename all above files:\n\n```\nrename -e 's/www/web/' *.ccd\n```\n\nAfter this the files are now called   \nweb.example.com-....   \n....\n\nThe only problem is, the syntax varies from one Linux distribution to another, so check the syntax before you use _rename_.\n\nFor Arch Linux I found that something like this would work:\n\n```\nrename www web *.ccd\n```\n\nThe expression \"\\*.ccd\" defines which files to act on, so this will act on all files that match \"\\*.ccd\\*, in the example above you could also use \"www.example.com-\\*.ccd\" or something similar.\n\nMain thing I wanted to get out there is, there is an easy tool to batch rename files instead of some complex if-for bash code. Which I tried to use before but failed at.\n","content_format":"markdown","date":"2019-04-29T20:06:29Z","description":"... is an easy to use and powerful tool, it can be used to replace part of file name (string1) with some other string. Something one can also do with some \"sed\" hack, but this tool is much easier to use, especially for beginners. You can get all information needed from \"rename --help\" (here from Lin","html_url":"https://newblog.utzer.de/2019/04/29/rename/","json_url":"https://newblog.utzer.de/2019/04/29/rename/index.json","lastmod":"2019-04-29T20:06:29Z","markdown_url":"https://newblog.utzer.de/2019/04/29/rename/index.md","media":[],"schema_version":1,"tags":["Arch","cli","hack","rename","Ubuntu"],"title":"rename","type":"blog_post"}