I need some help with bash processing of a text file. In my effort to clean up decades worth of windows use I have written a simple command to find all the instances of a specific file - specifically all the desktop.ini files. The results of this are perfect as far as I can tell.
find . -name "desktop.ini" > ~/desktop-ini.txt gives me 1038 rows of:
./Billy Joel/Greatest Hits, Vols. 1 & 2 (1973-1985), Disc 1/desktop.ini
./Billy Joel/Greatest Hits, Vols. 1 & 2 (1973-1985), Disc 2/desktop.ini
./Billy Joel/desktop.ini
So now, I'd like to delete all these files using a shell script but as you can see there are a ton of unpredictable "special characters" that will derail the simple rm <$filepath> script. I did try (once) a single line enclosing the whole string in single (') quotes - and it worked.
rm './Aerosmith/Classics Live!, Vol. 2/desktop.ini'
But in the shell script (and replacing rm syntax with ls syntax) it crashes gloriously (of course). Can someone point me to a 'how-to' or resource (besides a general regex, sed, or awk text) to see how to handle the file path so it is presented correctly?
I thought of a few things like counting the '/' characters, finding the last one, create a new string, 'cd' to that directory, delete the file, move back to the root and repeat. This makes logical sense, but it requires the string to not break the code - which it does (so far). Thanks for any ideas on this.