LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 10-09-2012, 06:32 AM   #1
berba9
LQ Newbie
 
Registered: Oct 2012
Posts: 2

Rep: Reputation: Disabled

I have a folder containing approximately:

100,000 files of type *.mol2

100,000 files of type *.pdbqt (with the same names as the *.mol2)

and around 16,000 folders named after the 1st 16,000 of these files.



I need to remove the 1st 16,000 files of *.pdbqt.
Is this possible?


The only idea I have is:
Take a folder name as my temp variable, and delete the *.pdbqt file with that name, and repeat...
Is there any script for this?

Please help.

Oops. The title should be removing not renoming.

Last edited by colucix; 10-09-2012 at 07:38 AM.
 
Old 10-09-2012, 09:03 AM   #2
Mr. Alex
Senior Member
 
Registered: May 2010
Distribution: Arch + X.org + IceWM
Posts: 1,202

Rep: Reputation: Disabled
You can do this in file manager like Dolphin. It shows how many files are selected at the moment. So you can select first, hold Shift and select last of those 16,000 (use scrollbar). And then delete.
 
Old 10-09-2012, 09:16 AM   #3
suicidaleggroll
Senior Member
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 2,846

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Something like this might work:

Code:
ls *.pdbqt | head -n 16000 | xargs rm -f
Note that this is untested, make a backup of the files in the folder just in case it does something unpredictable.

Last edited by suicidaleggroll; 10-09-2012 at 10:41 AM. Reason: typo
 
1 members found this post helpful.
Old 10-10-2012, 09:10 AM   #4
berba9
LQ Newbie
 
Registered: Oct 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
I just tried it, and it removed them all!

I hadn't done any backup, but thankfully it's just a tutorial (which had gone wrong and I thought this would be a quick-fix.)
 
Old 10-10-2012, 10:56 AM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,310
Blog Entries: 54

Rep: Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860
A take on suicidaleggroll's suggestion (there's reasons why you shouldn't use 'ls'):
Code:
find /some/directory -type f -iname \*.pdbqt printf "rm -f \"%p\"\n"|head -n 16000|/bin/sh
(but then again piping to '/bin/sh' may be bad too in some cases.) And since you managed to fsck up the first time maybe try the elaborate and slower version allowing you to see what it does:
Code:
COUNTER=1; find /some/directory -type f -iname \*.pdbqt | while read ITEM; do
 echo rm -f "${ITEM}"
 ((COUNTER++))
 echo $COUNTER
 [ $COUNTER -eq 1600 ] && exit 0 
done
If you have ensured it does what you want then remove the "echo " in front of the 'rm' command and remove the whole "echo $COUNTER" line.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
manually removing the .vdi files left over after removing VirtualBox adityavpratap Linux - General 2 10-24-2010 12:04 PM
removing KDE and Kubuntu specific files skazhy Ubuntu 1 09-09-2009 03:45 PM
My samba share is blocking specific extensions. rpg2 Linux - Security 2 04-13-2005 09:57 AM
Removing specific files twantrd Linux - General 3 03-01-2004 04:49 PM
QMail and blocking specific extensions Rob de Jong Linux - General 1 05-01-2002 02:11 PM


All times are GMT -5. The time now is 11:31 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration