Windows port of GSAR causes FOR loop to repeat on USB flash drives?

Microsoft Windows
Post Reply
Rekrul
Posts: 52
Joined: 2021-Aug-15, 11:29 pm

Windows port of GSAR causes FOR loop to repeat on USB flash drives?

Post by Rekrul »

The script below uses a Windows port of GSAR to perform a search and replace operation on all the TXT files in the current directory. It changes the word "test" to "text".

If I run this script on files on a hard drive, either internal or external USB, it works perfectly. Each files is processed once. If I run the script on files on a flash drive, each file is processed twice. It's not that each file comes up twice, the entire loop repeats twice.

File1.txt
File2.txt
File1.txt
File2.txt

More instances of GSAR in the loop will cause the loop to repeat even more times.

I have tried several different flash drives, formatted as both FAT32 and exFAT, and the results were the same.

It works fine with other commands, but not with GSAR. Does anyone have any idea why this happens?

I'm using GSAR 1.21 from here;

https://gnuwin32.sourceforge.net/packages/gsar.htm

Code: Select all

@echo off
for %%F in (*.txt) do (
echo %%F
gsar -stest -rtext -o %%F >nul
)
Simon_Weel
Posts: 36
Joined: 2021-Dec-13, 3:53 pm

Re: Windows port of GSAR causes FOR loop to repeat on USB flash drives?

Post by Simon_Weel »

Pretty weird?

Not an answer to your question, but I use FNR (Find and Replace).
Rekrul
Posts: 52
Joined: 2021-Aug-15, 11:29 pm

Re: Windows port of GSAR causes FOR loop to repeat on USB flash drives?

Post by Rekrul »

Simon_Weel wrote: 2023-Sep-04, 8:11 am Pretty weird?
Does this happen to anyone else, or is it just me?
Simon_Weel wrote: 2023-Sep-04, 8:11 am Not an answer to your question, but I use FNR (Find and Replace).
gsar can do more than just replace text. It will process any type of file and replace whatever you tell it. Aside from plain text, the characters to search and replace can be entered as byte values in decimal or hex.

One of my scripts using it igoes through text I've copied off the web and changes it to bog-standard text. This means changing dedicated opening and closing quotation marks to the generic ones, changing the ellipsis character to three periods, and changing whatever character they use for a dash to a plain dash.

Another script automatically corrects common errors in text-based subtitle files. Also, since my text editor of choice is fairly old and can't handle non-text characters, I added an option to change the dedicated music symbol to "##", and a second option to change them back. This lets me safely edit subs with the music symbol, or to easily add the music symbol by using "##" as a placeholder.
Post Reply