If all those files are in a directory you could cd to the parent of that directory and then rm the whole directory.
eg. the garbage files are in /mnt/work/BADDIR
and BADDIR contains ONLY those files you want to delete.
you could
- Code: Select all
cd /mnt/work
rm -R BADDIR
If there are files in BADDIR you want to keep you could do something like this:
- Code: Select all
find BADDIR -name '*' -exec mv \{\} \{\}_goodsfx_$RANDOM \;
this will rename the files keeping their current messed up name, but appending the string _goodsfx_nnnnn
to them, where nnnn is a random integer.
Now each file has a unique name you can refer to.
say your directory now looks like this:
badname1_goodsfx_3206
badname2_goodsfx_1209
badname3_goodsfx_30555
where the 'badname' part of the above example is the filename you cant type in.
and you want to keep badname3 but delete the others. Of course you cant type the character string badname3 because it is messed up.
you could say though
mv BADDIR/*goodsfx_30555 GOODDIR/goodname3
to move badname3 out of BADDIR to GOODDIR and give it a new name that you like.
in spite of the wild card only one file will move because the digits at the end are unique. or should be.
now with the good files moved out of BADDIR you can say rm -R BADDIR as before.
pgmer6809