Advertisement
thioshp

Batch Rename: Rename Multiple Files in Linux Terminal

Mar 31st, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. 1. for f in *.txt;do mv ${f%txt}{txt,md}; done
  2.  
  3. 2. for f in *.md; do mv "$f" "${f%\.md}.txt
  4.  
  5. 3. mv $old `basename $old .txt`.md;
  6.  
  7. 4. rename .txt .md *.txt
  8.  
  9. 5. rename 's/.txt/.md/i' *
  10.  
  11. 6. mmv "*.txt" "#1.md"
  12.  
  13. 7. install mmv then use any of the following examples:
  14. #Rename all *.jpeg files in the current directory to *.jpg:
  15.  
  16. # mmv '*.jpeg' '#1.jpg'
  17. # Replace the first occurrence of abc with xyz in all files in the current directory:
  18. # mmv '*abc*' '#1xyz#2'
  19. # Rename files ending in .html.en, .html.de, etc. to ending in .en.html, .de.html, etc. in the current directory:
  20. # mmv '*.html.??' '#1.#2#3.html'
  21. # Rename music files from <track no.> - <interpreter> - <song title>.ogg to <interpreter> - <track no.> - <song title>.ogg in the current directory:
  22. #
  23. # mmv '* - * - *.ogg' '#2 - #1 - #3.ogg'
  24.  
  25. 8. for f in *.txt;do mv ${f%txt}{txt,md}; done
  26.  
  27. 9. for f in *.txt; do mv $f `basename $f .txt`.md; done;
  28.  
  29. 10. rename 's/\.txt$/\.md$/i' *
  30.  
  31. Source: http://www.commandlinefu.com/commands/view/7351/batch-rename-extension-of-all-files-in-a-folder-in-the-example-from-.txt-to-.md
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement