I have a bunch of directory, sub-directory, and filenames that were created in Linux with the following pattern: YYYY - MM - DD T HH : MM : SS (I added spaces for clarity but no spaces are in the directory/sub/file names; YYYY, MM, DD... are integers and '-', 'T', ':' are constants of the expression).
These directories/files were copied to Windows and then back to Linux, and the ':' got corrupted. Each place where there should be ':' there is '\357\200\242' which shows up as ??? when I do
I know that fixing this should not be too complicated using a combination of
sed, but I'm very rusty on my piping, regex, and
So far I have this
for a in *T*???*???*; do mv "$(echo "$a" | sed [***])"; done
[***] should be a regex that changes
*T*:*:* where the middle two
* are each two digits. And this should rename both files and directories, recursively. I also suspect that
??? is not the correct input pattern to use here.
I've seen a bunch of posts offering a combination of
rename, but again, I am a bit rusty on the use of regex, and could not arrive at a good solution for this situation.