Use Rename to Rename Files

Recently I begin to use Onedrive to store my photos instead of Dropbox. When I try to move my photos from Dropbox to Onedrive, I find that Onedrive and Dropbox use different forms to name photos taken by cell phone. Onedrive uses YYYYMMDD_HHMMSS.jpg and Dropbox uses YYYY-MM-DD HH.MM.SS.jpg. So I want to rename my photos files in Dropbox to match Onedrive form. As I use macOS so software rename can be a good choice. Use homebrew to install rename if you like.

Then I use command

$ rename 's/^(\d{4})-(\d{2})-(\d{2})[ ](\d{2})\.(\d{2})\.(\d{2})/$1$2$3_$4$5$6/' *.

Rename uses regex and more reference about “regex” can be found here.

comments powered by Disqus