Escape illegal filename characters in Windows

This commit is contained in:
Alex Ling 2020-12-28 15:20:09 +00:00
parent f7b8e2d852
commit b6a204f5bd

View File

@ -139,9 +139,13 @@ module Rename
post_process str post_process str
end end
# Post-processes the generated file/folder name
# - Handles the rare case where the string is `..`
# - Removes trailing spaces and periods
# - Replace illegal characters with `_`
private def post_process(str) private def post_process(str)
return "_" if str == ".." return "_" if str == ".."
str.gsub "/", "_" str.rstrip(" .").gsub /[\/?<>\\:*|"^]/, "_"
end end
end end
end end