From 2140ab51deed88e90eafebf9520fa5f9995dc7c9 Mon Sep 17 00:00:00 2001 From: twells46 <173561638+twells46@users.noreply.github.com> Date: Wed, 31 Dec 2025 13:28:05 -0600 Subject: Migrate from stow --- private_dot_local/bin/executable_rename-fat32 | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 private_dot_local/bin/executable_rename-fat32 (limited to 'private_dot_local/bin/executable_rename-fat32') diff --git a/private_dot_local/bin/executable_rename-fat32 b/private_dot_local/bin/executable_rename-fat32 new file mode 100644 index 0000000..25fc947 --- /dev/null +++ b/private_dot_local/bin/executable_rename-fat32 @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby +# Encoding : UTF-8 + +class RenameFAT32 + def initialize(*args) + @files = args.map do |file| + File.expand_path(file) + end + end + + def make_fat32_compliant(value) + # Remove characters not allowed in fat32 + value = value.to_s.gsub(/([\?\/\*\|:;"”“<>])/, "").strip + # Double spaces + value = value.gsub(/ {2,}/," ") + # Bad quotes + value = value.gsub('’', "'") + return value + end + + def run + @files.each do |file| + dirname = File.dirname(file) + extname = File.extname(file) + basename = File.basename(file, extname) + new_basename = make_fat32_compliant(basename) + new_file = File.join(dirname, new_basename+extname) + + File.rename(file, new_file) if file != new_file + end + + end +end +RenameFAT32.new(*ARGV).run() -- cgit v1.2.3