LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-17-2005, 11:44 AM   #1
dhave
Member
 
Registered: Oct 2004
Location: still outside the Matrix
Distribution: Arch, formerly Gentoo and Slackware
Posts: 438

Rep: Reputation: 31
Need a dupe-killer, please


I'm looking for a simple utility or script that will compare the contents of two directories and then delete all the files in directory A which are also found in directory B.

Ideally, I'd like to be able to control the parameters of the file-matching based on size, date of creation, date of modification, permissions, and perhaps other properties.

Also, I'd like the utility to make a backup of the files it deletes just in case.

I'm trying to clean out a directory into which I copied a whole bunch of libraries by mistake. I don't want to disturb the previous contents of the directory, however, and I'm not confident of the

Does this exist ready-made, or can someone help me know how to write a simple utility to do this? Warning: I'm an English major, O.K.? But I do know which end of the power cord to plug into the wall. Usually.
 
Old 01-17-2005, 12:49 PM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Try this (use full paths in DIR1 DIR2 and BACKUP, and make sure the BACKUP directory exists) This'll just delete duplicate files based on filename.

Code:
#!/bin/bash
DIR1=<insert first directory path>
DIR2=<directory files will be deleted from>
BACKUP=<insert backup directory>
cd "$DIR1"
for GO in `ls`
  do
  cp "$GO" "$BACKUP"
  rm "$DIR2/$GO"
done
Usual disclaimers apply.

Dave

Last edited by ilikejam; 01-17-2005 at 12:51 PM.
 
  


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
looking for a time[d]killer : ) fetusba Linux - Newbie 1 05-12-2005 08:57 PM
remove dupe wireless interface amp_man Ubuntu 2 03-31-2005 02:03 PM
spam killer? sgtbob Linux - Newbie 1 08-23-2004 06:52 AM
mysql dupe entry error, how to avoid? hydro Linux - Software 0 09-20-2003 12:08 PM
Popup Killer Half_Elf Linux - Security 1 04-07-2002 04:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:23 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration