9
Advice neededI need linux help getting short bash command (renaming problem files) to work. FIND + DETOX command
Posted October 28, 2024 by Maplefields in STEM

Update: Solved.

Found the problem. Removed the * from the code. I added the solution to the table. I just don't understand why this worked, and if someone can point to an explanation written in plain English, it would be much appreciated. When I was researching the Find command yesterday, I came across many examples in coding forums using * in the exec command. So I'm confused at when * is needed and when it isn't.


What I want it to do:

Recursively search directory for folders and filenames with special character "?", and fix the name of ONLY the targeted files/folders.

goal

I really want to know WHY find + detox isn't working.

Is there something I'm missing? Am I not supposed to use the -exec command with detox? is there some other way to combine find and detox?

What I've tried

CODE RESULT SUCCESS?
test:
find . -name "*[?]*" -print0 prints targeted files good
--------------------- --------------------- ---------------------
find . -name "*[?]*" -exec detox -nr --remove-trailing * {} \; detox acts on EVERY file in directory, not just my targeted ones bad
find . -name "*[?]*" -exec detox -nr --remove-trailing {} \; (removed the star) detox acts on targeted files only good
find . -name "*[?]*" -exec detox -n --remove-trailing {} \; (removed -r flag) (same thing) detox acts on targeted files only good

Currently, I'm resorting to this :

find . -name '*[?]*' -exec rename -n 's/[@\$\?]/_/g' {} \;

But then I have to clean up files that went from this

???sometext???????.txt

to this

__sometext______.txt

By using this more than once

find . -name '*__*' -exec rename 's/__/_/g' {} \;

I'm purposely avoiding replacing characters with no character 's/[@\$\?]//g'because some of the files have "?" in place of possessive apostrophes (e.g. people?s) and I'd rather preserve that there should be an apostrophe than look at "peoples."

Although what I'm doing is currently working, I'd really prefer it if my solution used the detox command.

4 comments

istaraMarch 4, 2025

I was disappointed to see the period underwear brand Modibodi having a section on their page for "trans girls" - just the sheer extortion of suggesting a biological boy buy their expensive underwear just to pretend-menstruate once a month.

And yet (happy to be corrected) I don't think there's a special page for "trans boys" - most of whom actually need period products.

PiquedInterestMarch 5, 2025(Edited March 5, 2025)

https://us.modibodi.com/products/mens-brief-moderate-heavy-black

https://us.modibodi.com/collections/all-gender

They do have a men's section for "men" that mentions "period peace" in the product description, and they have an "all genders" section that doesn't have any products list (haha). Where are you seeing a section for transwomen?

istaraMarch 5, 2025

I think they may have changed the pages on their site - it was on the Australian site - and I recall it being in one of the FAQs.

Google throws up this link - but the content has disappeared: https://www.modibodi.com/collections/all-gender (for "all gender" clothing)

And then here's some nonsense on a blog about biological males getting periods: https://www.modibodi.com/blogs/womens/transwomen-period - it has "tips" which include wearing period underwear, even though that page itself acknowledges that "some trans women don’t have uteruses" so won't bleed.

(I'd like to know what trans women do have uteruses, for what it's worth).

vulvapeopleMarch 5, 2025

"some trans women don’t have uteruses"

I'm guessing some dumbass at that company has bought into the TRA lies about uterus implants for women already having been done for TIMs.