[clug] file reorgs: moving files & maintaining directory structures

Steve Jenkin sjenkin at canb.auug.org.au
Sat Aug 26 09:32:49 UTC 2017


Dave,

thanks for the confirm on fdupes.

And thanks also for the better options for find. printf: much better than my use of xargs & stat :)

cheers
steve

> On 26 Aug 2017, at 18:51, David Deaves <david.deaves at dd.id.au> wrote:
> 
> 1. I have also found fdupes to be useful
> 2. I normally just copy it all and procrastinate cleaning it up!
> 
> 
> 
> This set of code could probably do what you seem to want in terms of moving a bunch
> of files (oldest approximately half - I took your 100,000 as accurate)
> 
> 
> find . -type f -printf '%T@ -*- %p\n'  |        # Get files with mtime in Seconds (and decimals)
> sort -n  |     # Sort from oldest to newest
>  sed 's/^[0-9.]* -*- //' |     # Prune Seconds and delimiter from front
>   head -50000 |        # Select oldest half - or send this to a file and prune where you want
>    cpio -pvdm /mnt/some/new/location   |  # Copy them - stdout will be the list of successful copies
>     xargs -d '\n' rm           # Clean up those copied
> 
> 
> Break the pipeline where ever you want to give you the control you need
> 
> If you want to edit the initial list to find a logical brake you may want to add %t
> to your find line to get a human readable time
> 
> find . -type f -printf '%T@ %t -*- %p\n'  |     # Get files with mtime in Seconds (and decimals)
> sort -n  > /tmp/temp_file      # Sort from oldest to newest
> 
> 
> Dave !

--
Steve Jenkin, IT Systems and Design 
0412 786 915 (+61 412 786 915)
PO Box 38, Kippax ACT 2615, AUSTRALIA

mailto:sjenkin at canb.auug.org.au http://members.tip.net.au/~sjenkin




More information about the linux mailing list