Sample Header Ad - 728x90

rename first two periods to hyphens

1 vote
2 answers
146 views
I have the following command to change periods to hyphens in file names recursively, so long as they have another period both before and after them: find path/to/dir -depth -type f -name '*.*' -exec rename -n -d 's/(?<=.)\.(?=.*\.)/-/g' {} + However it cant be used effectively on all filenames I wish to adjust, and needs to be rewritten according to the following rules: 1. Renaming only occurs on filenames that start with a number. 2. Hidden files do not get changed. 3. Only the first two periods in every filename get changed. Eg: 2020.12.06_name123.ext.xmp becomes 2020-12-06_name123.ext.xmp while name123.ext.xmp remains unchanged. How to solve? Running linux mint cinnamon 21
Asked by ItHertz (97 rep)
Feb 10, 2023, 12:22 PM
Last activity: Feb 11, 2023, 09:43 AM