Issue
Google Drive went a little crazy and create multiple iterations of files by appending multiples of "(1)", "(1) (1)" to the file names. So far I've been able to get a decent list of them with their path by using:
tree -f -ifpugDs $PWD | grep -e '(1) (1)' | cut -d "]" -f 2 > output.txt
Now I'm having trouble on how to delete them with the rm command. I Don't mind deleting a few of them by hand that the filter didn't pick up ( like "(2) (1)" ), but there are around 45K of them that the filter matched with.
Solution
This will delete every file whose name ends in (1)
, recursively:
find . -name '*(1)' -exec rm {} +
-name '*(1) (1)'
to only delete files ending with a double 1.-name '*([0-9])'
will match any single digit.find . -mindepth 1 -maxdepth 1 -name '*(1)' -exec rm {} +
for no recursion.- I would do
find . -name '*(1)' -exec echo rm {} \;
to print a neat list of therm
commands to be executed. Review it, then removeecho
to run for real. - Changing
\;
back to+
is optional,+
is more efficient.
Answered By - dan Answer Checked By - Gilberto Lyons (WPSolving Admin)