all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Deleting files
@ 2021-02-21 23:01 michael-franzese
  2021-02-21 23:08 ` Emanuel Berg via Users list for the GNU Emacs text editor
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: michael-franzese @ 2021-02-21 23:01 UTC (permalink / raw)
  To: Help Gnu Emacs

I have two directories with files, one is the "source", the other
"destination".  I would like to have a script that checks file
in "source".  If file name and size matches that at "destination",
the file at "source" is deleted.  Preferably using bash.






^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Deleting files
  2021-02-21 23:01 Deleting files michael-franzese
@ 2021-02-21 23:08 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-02-21 23:15   ` michael-franzese
  2021-02-22  5:19 ` Jean Louis
  2021-02-22 16:22 ` TRS-80
  2 siblings, 1 reply; 6+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-02-21 23:08 UTC (permalink / raw)
  To: help-gnu-emacs

michael-franzese wrote:

> I have two directories with files, one is the "source", the
> other "destination". I would like to have a script that
> checks file in "source". If file name and size matches that
> at "destination", the file at "source" is deleted.
> Preferably using bash.

But why do you ask script/bash questions here?

Better ask at gmane.comp.shells.bash.help

https://lists.gnu.org/mailman/listinfo/help-bash

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Deleting files
  2021-02-21 23:08 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-02-21 23:15   ` michael-franzese
  0 siblings, 0 replies; 6+ messages in thread
From: michael-franzese @ 2021-02-21 23:15 UTC (permalink / raw)
  To: moasenwood; +Cc: help-gnu-emacs






> Sent: Monday, February 22, 2021 at 11:08 AM
> From: "Emanuel Berg via Users list for the GNU Emacs text editor" <help-gnu-emacs@gnu.org>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Deleting files
>
> michael-franzese wrote:
>
> > I have two directories with files, one is the "source", the
> > other "destination". I would like to have a script that
> > checks file in "source". If file name and size matches that
> > at "destination", the file at "source" is deleted.
> > Preferably using bash.
>
> But why do you ask script/bash questions here?
>
> Better ask at gmane.comp.shells.bash.help
>
> https://lists.gnu.org/mailman/listinfo/help-bash

forgot that i could do that.

> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Deleting files
  2021-02-21 23:01 Deleting files michael-franzese
  2021-02-21 23:08 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-02-22  5:19 ` Jean Louis
  2021-02-22 16:22 ` TRS-80
  2 siblings, 0 replies; 6+ messages in thread
From: Jean Louis @ 2021-02-22  5:19 UTC (permalink / raw)
  To: michael-franzese; +Cc: Help Gnu Emacs

* michael-franzese@gmx.com <michael-franzese@gmx.com> [2021-02-22 02:02]:
> I have two directories with files, one is the "source", the other
> "destination".  I would like to have a script that checks file
> in "source".  If file name and size matches that at "destination",
> the file at "source" is deleted.  Preferably using bash.

By using Emacs
==============

In Emacs that is already solved by using the function as below:

M-x dired-compare-directories

Process would be as following:

0. I advise to set the variable `dired-dwim-target' to TRUE, as "dwim"
   means "Do What I Mean". This variable will help Dired file
   operations to automatically offer the other window's directory.

1. Open two (or more) Emacs windows, one directory in one window,
   other directory in other window.

2. M-x dired-compare-directories

3. It will ask you for Lisp expression, you may then say something
   like: (not (= size1 size2)) in the prompt. That will compare
   directories by sizes. Those files with different sizes will be
   marked in both windows, you will chose from which window and
   directory to transfer files to other window.

4. Use `C' in Dired to copy or `R' to rename files to other window and
   directory.

It is possible to make it a script with Emacs, as Emacs may run in
batch mode. You would need to first change to specific directory by
using the `source' argument, and then supply `DIR2' variable by using
the `target' argument of a script, and I just guess without checking
that predicate would be the Lisp function as explained.

(dired-compare-directories DIR2 PREDICATE)

More about that may be found in the manual by evaluating this Lisp
expression:

(info "(emacs) Misc Dired Features")

By using Midnight Commander
===========================

Without Emacs, I know that this function exists in software Midnight
Commander, the command being `mc' and key binding C-x d, so by
invoking the function in Midnight Commander you also get it.

Such function depends on probability that the outcome will be as
wanted.

As what if file contains a phone number, but newer file contains newer
and current phone number. That makes both files of the same size and
older file would not get overwritten by the new file. Files may be
changed and still retain the same file size. Probability is law but is
still there. Data may be loss when relying on such function.

For Bash
========

Thus when using the Bash script, I would make sure that each file is
checked for its hash before deciding if to move it and later delete
it.

By using Rsync
==============

Rsync command offers the same functionality automatically. Thus
something like this:

$ rsync --remove-source-files -av /source/directory/ /target/directory/

would make sure that source files are deleted after synchronizing
those files from source directory.

In my opinion rsync would be most appropriate for you and I suggest
that you review its options and manual.

Jean



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Deleting files
  2021-02-21 23:01 Deleting files michael-franzese
  2021-02-21 23:08 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-02-22  5:19 ` Jean Louis
@ 2021-02-22 16:22 ` TRS-80
  2021-02-22 18:37   ` michael-franzese
  2 siblings, 1 reply; 6+ messages in thread
From: TRS-80 @ 2021-02-22 16:22 UTC (permalink / raw)
  To: help-gnu-emacs

On 2021-02-21 18:01, michael-franzese@gmx.com wrote:
> I have two directories with files, one is the "source", the other
> "destination".  I would like to have a script that checks file
> in "source".  If file name and size matches that at "destination",
> the file at "source" is deleted.  Preferably using bash.

This may not be exactly what you are looking for, but there is also
Syncthing[0], which does continual, automatic folder synchronization
(bidirectional, or send / receive only).

The reason I mention it, is because your workflow sounds vaguely
reminiscent of how I manage my photos.

I take almost all photos on my Android phone.  They are synced (more or
less) immediately with Syncthing to my NAS at home (in reality, a small
SBC[1] running Armbian[2]).

Then nightly (automatically, via cron), I run the sortphotos Python
script, which moves the photos from the upload/sync folder into their
final locations in a date based folder tree with consistent filenames
which I call the timeline[3], along with giving them consistent filename
format.[4]

After that, I am free to add descriptions, tags, etc. on top of the base
file name.

Anyway, may or not be directly relevant, just thought I would mention it
just in case.

Cheers,
TRS-80

[0] https://syncthing.net/
[1] Single Board Computer, see
https://www.armbian.com/download/?device_support=Supported for examples
[2] Debian for SBCs https://www.armbian.com/
[3]
https://git.sr.ht/~trs-80/ostrta-spec/tree/HEAD/Specifications.md#filesystem
[4] 
https://git.sr.ht/~trs-80/ostrta-spec/tree/HEAD/Specifications.md#filename



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Deleting files
  2021-02-22 16:22 ` TRS-80
@ 2021-02-22 18:37   ` michael-franzese
  0 siblings, 0 replies; 6+ messages in thread
From: michael-franzese @ 2021-02-22 18:37 UTC (permalink / raw)
  To: TRS-80; +Cc: help-gnu-emacs






> Sent: Tuesday, February 23, 2021 at 4:22 AM
> From: "TRS-80" <lists.trs-80@isnotmyreal.name>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Deleting files
>
> On 2021-02-21 18:01, michael-franzese@gmx.com wrote:
> > I have two directories with files, one is the "source", the other
> > "destination".  I would like to have a script that checks file
> > in "source".  If file name and size matches that at "destination",
> > the file at "source" is deleted.  Preferably using bash.
>
> This may not be exactly what you are looking for, but there is also
> Syncthing[0], which does continual, automatic folder synchronization
> (bidirectional, or send / receive only).
>
> The reason I mention it, is because your workflow sounds vaguely
> reminiscent of how I manage my photos.
>
> I take almost all photos on my Android phone.  They are synced (more or
> less) immediately with Syncthing to my NAS at home (in reality, a small
> SBC[1] running Armbian[2]).
>
> Then nightly (automatically, via cron), I run the sortphotos Python
> script, which moves the photos from the upload/sync folder into their
> final locations in a date based folder tree with consistent filenames
> which I call the timeline[3], along with giving them consistent filename
> format.[4]
>
> After that, I am free to add descriptions, tags, etc. on top of the base
> file name.
>
> Anyway, may or not be directly relevant, just thought I would mention it
> just in case.

Will surely check it out.  I like to go through good designs.

> Cheers,
> TRS-80
>
> [0] https://syncthing.net/
> [1] Single Board Computer, see
> https://www.armbian.com/download/?device_support=Supported for examples
> [2] Debian for SBCs https://www.armbian.com/
> [3]
> https://git.sr.ht/~trs-80/ostrta-spec/tree/HEAD/Specifications.md#filesystem
> [4]
> https://git.sr.ht/~trs-80/ostrta-spec/tree/HEAD/Specifications.md#filename
>
>



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-02-22 18:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-21 23:01 Deleting files michael-franzese
2021-02-21 23:08 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-21 23:15   ` michael-franzese
2021-02-22  5:19 ` Jean Louis
2021-02-22 16:22 ` TRS-80
2021-02-22 18:37   ` michael-franzese

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.