LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 12-05-2023, 07:18 PM   #1
ericlindellnyc
Member
 
Registered: Jun 2017
Posts: 182

Rep: Reputation: Disabled
RMLINT -- move files instead of deleting them


I'm using RMLINT as a substitute for DUPEGURU, which is CPU- and RAM-intensive. However, RMLINT doesn't give me the option of moving duplicate files to a new folder instead of deleting them -- a feature that DUPEGURU has and which I can't find on any command-line script.
This is important, especially when I'm new to RMLINT, to avoid accidental erasures by keeping duplicates for a while before deleting.

I see a feature request from 2017, though I don't know if it's been implemented.
It's hard to find a command-line script that does all I need, including
searching for duplicate files or folders
only matches with the same name
using a reference folder
selecting file types to delete by extension
dry runs
moving duplicate hierarchy to separate folder

Last edited by ericlindellnyc; 12-05-2023 at 07:22 PM. Reason: addition
 
Old 12-05-2023, 07:29 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,148

Rep: Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124
Never used it (there are a plethora of CLI tools out there), but their own doco states:
Quote:
rmlint itself WILL NOT DELETE ANY FILES. It does however produce executable output (for example a shell script) to help you delete the files if you want to.
Most of the (useful) tools do likewise. It's just a script, hack it to your needs.

Edit: Missed the update as I was off looking for the doco. Get a tool that does most of what you want, and then manage it in the script. All the heavy lifting should be done for you.

Last edited by syg00; 12-05-2023 at 07:35 PM.
 
Old 12-05-2023, 09:31 PM   #3
ericlindellnyc
Member
 
Registered: Jun 2017
Posts: 182

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
Never used it (there are a plethora of CLI tools out there), but their own doco states:Most of the (useful) tools do likewise. It's just a script, hack it to your needs.

Edit: Missed the update as I was off looking for the doco. Get a tool that does most of what you want, and then manage it in the script. All the heavy lifting should be done for you.
That's a good idea. The rm command in the output file can be replaced with mv. But it helps to move the entire directory structure of duplicate files -- as dupeguru does. Dupeguru does everything I need, except it's so RAM/CPU-hungry that I can use it only on limited numbers of files.

I don't trust any script, app, or myself for that matter -- to handle this without error, which is why I insist on moving the files instead of deleting -- at least for a while.

I believe dupeguru does byte-for-byte comparison, which could account for its inefficiency. I can't find a switch to use only the hashing algorithm.

Thanks for your reply.
 
Old 05-17-2024, 08:43 PM   #4
ericlindellnyc
Member
 
Registered: Jun 2017
Posts: 182

Original Poster
Rep: Reputation: Disabled
Update -- rmlint -- move files rather than delete

Update. I am trying to use rmlint to remove duplicates. I dont want to delete them -- just move them to a different drive. I would like the original directory structure preserved.

My original command was executed from:
Code:
/Volumes/rmlintTest/testData15may24/
The original command was
Code:
rmlint -gvbex -T df /Volumes/rmlintTest/testData15may24/
The destination tmp was at
Code:
/Volumes/rmlintTest/testData15may24/tmp
which produces a ".sh" output file containing the original rm_command code. I replaced that code with the following -- taken from rmlint documentation.

Code:
remove_cmd() {
    echo 'Deleting:' "$1"
    if original_check "$1" "$2"; then
        if [ -z "$DO_DRY_RUN" ]; then
            # was: rm -rf "$1"
            mv -p "$1" "/tmp$1"
        fi
    fi
}
Here, I tried moving "$1" up a level from "." level -- namely a folder called tmp.
However, the folder tmp is misconstrued as being below Volumes, like this -- in MacOS.
cp: tmp/Volumes/rmlintTest/testData15may24/dir2/11-testLint.txt: No such file or directory.

I've tried cp instead of mv -- by cd'ing into the target folder before cp'ing. That does move the files -- but doesn't preserve the folder structure.

I've been on this for a while and am totally stumped. Assistance appreciated.
 
Old 05-18-2024, 09:24 AM   #5
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,821

Rep: Reputation: 1212Reputation: 1212Reputation: 1212Reputation: 1212Reputation: 1212Reputation: 1212Reputation: 1212Reputation: 1212Reputation: 1212
Maybe mkdir the path first?
Code:
    newfn="/tmp/${1#/}"
    mkdir -p "${newfn%/*}" &&
    mv -v "$1" "$newfn"
 
  


Reply



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
list directories where all foles are dumpicated (rmlint) funkytwig Linux - General 6 04-01-2019 02:15 PM
LXer: Make “rm” Command To Move The Files To “Trash Can” Instead Of Removing Them Completely LXer Syndicated Linux News 0 10-11-2017 11:30 PM
rmlint-2.0.0 - a lint/duplicate finder [rewrite of old rmlint, testers wanted] sahib_bommelig Linux - General 13 10-25-2015 09:55 AM
del command to remove files to directory instead of completly deleting them. bettsy583 Linux - Newbie 1 12-02-2010 04:30 PM
[SOLVED] Bash script: how to move files to Trash instead of deleting? KonfuseKitty Programming 1 07-10-2010 12:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:06 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