LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How can I type a command that does the following? (https://www.linuxquestions.org/questions/linux-newbie-8/how-can-i-type-a-command-that-does-the-following-553050/)

KevinAlaska 05-10-2007 11:39 PM

How can I type a command that does the following?
 
Hello and thank you first off for reading my post.

I have ubuntu 7 and I have recently imported from about 5 different backups from several different computers on my home network photos using fstop photo manager.

This program if you have not used it can import photos from selected locations. I have selected all these backups because I am not sure which files are not double, triples etc of the same photo.

So once the import is done it places all the newly copied photos from the import into my ubuntu gnome home folder called "photos".

If there are double that are imported into the "photo" folder (which I should add. all photos imported are put into subfolders by date for example a photo from January 15, 2002 would be put into a folder /photo/2002/01/15/) these duplicates are renamed with a *-1.jpg, *-2.jpg, *-3.jpg etc. The '*'would be the original photos name in its place.

So here is my question...

How can I type a command that would go in and delete all files with the -1.jpg at the end of the files name or -2, -3 etc and in all the subdirectories or maybe move them into a single folder. I just need to get them out of there. The idea of scrolling through 10k of photos and deleting them all one by one sounds like NASTY work to me.

Thanks for your help and time on this issue.

Cheers and best wishes from me.

Sincerely,

Kevin in Alaska

fukawi2 05-10-2007 11:44 PM

To find all the photos named like that:
Code:

find /home/username/photo -type f -iname \*-1.jpg -print
To move them elsewhere
Code:

find /home/username/photo -type f -iname \*-1.jpg -exec mv -vf {} /home/username/duplicate-photos \;
To delete them:
Code:

find /home/username/photo -type f -iname \*-1.jpg -exec rm -Rfv {} \;

KevinAlaska 05-10-2007 11:46 PM

SWEET.. thank you SOOOOO much.

I knew there was a way. And awesome fast responce to my post. Under 5 minutes.

Thanks a mill!!!

Cheers

fukawi2 05-10-2007 11:54 PM

Pleasure.. Glad to help. Gotta have something to do at work :P

Linux looks after my servers so well - work is dead quiet these days :D

KevinAlaska 05-10-2007 11:58 PM

HAH!... That was funny.

Well if you don't mind a little down relaxing 'time to surf linuxqustions.org' time then thats GREAT!

I know some hate that but personally I don't mind it if I can keep busy in ways 'I' want to. :)

But again if severs are doing great then that means Linux and people are doing there jobs just fine. :)

I wish I had your job and mostly your knowledge of Linux.

Thanks again ALL the same. :)

Sincerely,

Kevin in Alaska


All times are GMT -5. The time now is 10:39 AM.