You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Mass_Renaming_Files.md 1.0 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
1234567891011121314151617181920212223242526272829303132333435363738
  1. ## Mass Renaming Files
  2. ### Introduction
  3. Mass renaming of files can vary depending on what platform and system
  4. you\'re on. If you\'re on Unix, and more specifically Unix, the
  5. following techniques should be available to you.
  6. If you\'re using RedBrick then both **mmv** and **rename** are available
  7. to you.
  8. In this scenario, we are going to try and rename all .php files in the
  9. current directory so they have a .gif extension
  10. **WARNING:** always backup your files
  11. ### Using mmv
  12. `mmv '*.php' '#1.gif'`
  13. ### Using rename
  14. `rename 's/\.php$/.gif/' *.php`
  15. ### In the Bash shell
  16. `for file in *.php; do mv "$file" "${file%.php}.gif"; done`
  17. ### Slightly more complex shell version
  18. This has the benefit of using a full regular expression in the sed part
  19. so you can do much more complex renames, it is also generally more
  20. widely available as rename is not available in as many places as ls,
  21. awk, sed and sh.
  22. `ls *.php | awk '{print("mv "$1" "$1)}' | sed 's/php$/gif/2' | /bin/sh`
  23. [Category:HowTo](/Category:HowTo "wikilink")