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.

blackgiulia
blackgiulia

放眼四野直至星穹,追溯时光直至永恒,需要思考的事情太多,每个生命的时间太少

comments powered by Disqus
Next
Previous