Total beginner to .bat programming, so please bear with me: I've been trying to convert a massive database of Unicode files collected from scientific instruments to ANSI format. Furthermore, I need to convert all these files to .txt files.
Now, the second part is pretty trivial -- I used to do it with the "Bulk Rename Utility", and I've been able to make it work so far, I think.
The first part should be pretty straight forward, and I've found multiple different similar questions, but they all seem to be for powershell, a single file, or end in long discussions about the specific encoding being used. One question seems to match mine exactly, but having tried their suggested code, only half the file seems to transfer fine, the other half comes through as nonsense code. I've been using the code:
for %%F in (*.001) do ren "*SS.001" "*SS1.001"
for %%F in (*.001) do type "%%F" >"%%~nF.txt"
and then deleting/moving the extra files.
I've converted the files by hand successfully in the past (left), but the current encoding seems to be failing (right): Side by side comparison of files encoded by hand vs by program
My questions are:
- Is it possible that a single file I get from my instrument is in multiple encodings (part UTF-8, part UTF-16), and that this is messing up my program (or more likely, i'm using an encoding that is too small)? If this is the case, I'd understand why the special characters like the squareds and the degree symbol are breaking, but not the data, which is just numbers.
- Is there some obvious typo in my code that is causing this bizarre error?
- If the error might be embedded in what unicode (8 vs 16 vs 32) or ANSI (1252 vs ???) I'm using, how would I check?
- How would I fix this code to work?
If there's any better questions I should be asking or additional information I need to add, please let me know. Thank you!!