changes file-extension based on mime-type
Go to file
Dym Sohin 3796f0c9f6 re-init 2023-06-20 17:22:54 +02:00
LICENSE Initial commit 2023-06-20 17:18:53 +02:00
install.sh re-init 2023-06-20 17:22:54 +02:00
meta.kdl re-init 2023-06-20 17:22:54 +02:00
readme.md re-init 2023-06-20 17:22:54 +02:00
rename-ext.sh re-init 2023-06-20 17:22:54 +02:00

readme.md

rename-ext

changes file-extension based on mime-type

also

  • removes *?|^:"<> characters from the file-name
  • reducing multiple spaces, dots, and underscores
  • adds rename-date suffix to ensure uniquness of the filename
  • strips exec-flag from non-executive types (usual leftover from FAT/NTFS)
  • optimizes images while at it (shows reduction size in kb and %)

install

  1. look at install file for instructions
  2. adjust PREFIX at wish
  3. make sure the final directory is on $PATH

use

rename-ext /Data/Pictures/_unsorted/**/*

to only change extension and nothing else:

rename-ext --only-ext /Data/Photos/2020/*

to only print a report:

rename-ext --test-run /Data/Docs/_dump/*

requires

todo

  • find better determination tool for application/octet-stream
  • leverage fd to do recursive paralel execution if some of parameters are folders

q&a

Q: why not just rename files to hashes of their contents, and store original filenames in some database?

A: good point. that database is in my case a filesystem itself.