From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 20EE2158020 for ; Wed, 23 Nov 2022 11:39:33 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 21D63E09C1; Wed, 23 Nov 2022 11:39:27 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 7A2B4E09B6 for ; Wed, 23 Nov 2022 11:39:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1669203559; bh=Ubv8mQ7fJyjAb3SCmK28kLfukFOPsmosS2/olvZocbE=; h=X-UI-Sender-Class:Date:From:To:Subject:References:In-Reply-To; b=a75rEng+L5H9AtIoiZm1/Be09Z4Alt9T33cLKH9u9ZA7Ivru+TWqkRYSbaIsiC1Eg fDTkg2O4yJHpQEMKSGV8Ecd4iOeb6eQ74skT2bEt23+wg2xzdnMOR9ubsSjJ90NWk0 pGC5dnv7/+PEUfPOLA1lYacaw20TanTcgp+f/d3cCGCwHGtuybH0MytzNCcnc0UpOw 1XPXNb/HXDPVDz/SL0s13+bbh6CbWnpUHe6WZYjH4VWurggqPQ7er76fLAik2/FnoK 7ggI0yMgiSRkHgEBfNcogF+1R55fYvpUsrsw3rQFzByzkd+chgTRzFxXwCw6Qn3Cb1 QkaAhSkNYVNTw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from tp ([92.117.59.95]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MXp5Q-1oPpjn0fK0-00YCIB for ; Wed, 23 Nov 2022 12:39:19 +0100 Date: Wed, 23 Nov 2022 12:39:17 +0100 From: Frank Steinmetzger To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] Dolphin and adding a option, if it exists. Message-ID: Mail-Followup-To: gentoo-user@lists.gentoo.org References: <6ef36d93-4d8a-d9a4-ca71-396040103a25@gmail.com> <20221006134500.6f0812b9@digimed.co.uk> <62ebaa87-f750-b233-f8b4-ee50ef00bdfa@gmail.com> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="753m0jv3VStoXdeG" Content-Disposition: inline In-Reply-To: User-Agent: Mutt 2.2.9; VIM - Vi IMproved 9.0 X-Provags-ID: V03:K1:hC5UNALvEZ8cLSyRsdtp81Z0fD+oC4nIkh85kTJGtczZUyuqQWm 8eG/aeRENlVgh57QtY1QHtsnAlCtGfvXaa33M661YZQqOcyN/pFcTO+v3CUoLe8kCxw3bgs Xk9wnj0gKpfyjHMegSH8MWZgqIXX6Lctt3EGvulDX66/kRWZUSbk0C3c8dVbEBq49bukLq2 oDpf+LxeihppvG3TUa6CQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:R+QR39NJrxg=;/aPKHXnhQ2n789z9kAivdJvUPMc LNa5npRJGTLDCh1hzN6K1UHcDNSlt1lkk/Ar9c2g8M+q3ZiVo5S6F1bIqEN7Lt7hOIyKeoUeu uK7GXqDZw+1b89rrwDsG5D5GOD5iDLJC/GakP6plC0tXjiBiHw7Yxb6oAMQbJHZvPUymtADXM tWnkhDr+xphgOMGQ18j4S5CaeD5WzpfeW6XBF7yD/Xr0iiHZ6QhpLOoj8hQbjQFcJv5uEWxQE o/DoGJWjsp+GfVU1zRxDJWHisuEFrN6OqXDEffDJ14VQ4YkXF6F+cf2DTYzfaS2OyJR0EWE0C Lt6q0T8xdZhkllSuRB3N/VJ9pttEJxuhvGChdLvPnjWBAjXYwqXcuwo3Greh9CPCeVP9mwMu4 /qsW7/bxlBTZfuUt7tJY8eQVuVOI3VwCaRvstgppOqYNe8sirPILqKh2mQEt/jyYnCOd+i0FA 5yvCI6KpOey47BlaE+NqFo7DMF3Tv2Mo5Uav8k7YPbQyvAJEzKr9TQKR6gv/aa4m8RH70WNpy vPprJ3s/AZzZcXyEbWIQDEsVz26hLI74Szyqk8lh2r0jYJm9Hw8GaFAkwEGt+48i1pU7vvzr1 qt4qPQGm+ufBPM6Dcx0GOTS0skaM3Go29mlshdA9e8OmMpfx2WNrHqIjDdib09sI0StcMAXX4 UGM0rsUg248oA2bXeNRADU/jRTOa+0uaAWMEsoUvMabeZIq6OZrB7NljiLYaei6VoMu7jLbUi 7Pp/SiMVijnqxIQUCAcEwartpFYZE/QE0o/f+4XXpoiPApXoU5szEoqwMXraE1Rwt4jMbmLSe g689NWqRzfS6uSKYgeTIRLziFfK7wmvKkPNghM5/OmI6TTEaLmIhgpcmnLXqug0rsbBhJQDQZ Piw+PHEvxnimci7fVIH7oh7m6VX1gCfwKLi1BUrINorwWjLhDv7ESdGEYn1fEYqeTWjcE/jos F5jYbQ== X-Archives-Salt: fbc50bf9-a123-4044-b0e3-969c5795482c X-Archives-Hash: a707f318f3638cd21a36937bd1ed9628 --753m0jv3VStoXdeG Content-Type: multipart/mixed; boundary="1TXAKe06dm1MiOrj" Content-Disposition: inline --1TXAKe06dm1MiOrj Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am Tue, Nov 22, 2022 at 06:17:09AM -0600 schrieb Dale: > Frank Steinmetzger wrote: > >> I added a little . on that last line before the extension bit.=C2=A0 I= 'm a > >> happy camper. > > Give me a nudge if you want the more luxurious version with interactive > > selection of the overwrite destination. I think I already started a > > prototype somewhere, but can=E2=80=99t find it right now. > > > > Feel free to share.=C2=A0 Even if I don't use it, someone else may find it > and make good use of it. There ya goo. As I suspected, I already wrote most of it in October right away, I only couldn=E2=80=99t find the file until now. I just had to fix th= e same bugs as in the first script (and some more in the additional parts :D ), and put some more grease into the interal logic and output strings. --=20 Gr=C3=BC=C3=9Fe | Greetings | Salut | Qapla=E2=80=99 Please do not share anything from, with or about me on any social network. =E2=80=9CTo some degree people say you should not micro-optimise. But if what you love is micro-optimisation, that=E2=80=99s what you should = do.=E2=80=9D =E2=80=93 Linus Torvalds --1TXAKe06dm1MiOrj Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=Mv #!/usr/bin/env bash # author: Frank Steinmetzger # version: 2022-11-23 # Helper functions ------------------------------------------------------------ # oops, something occured and the script must exit with an error message die() { echo "$PROGNAME error: ${@}" > /dev/stderr exit 1 } # move a file after printing an info text move() { echo " Moving '${1##*/}' -> '$2'" mv -f "$1" "$2" } # print help text usage() { cat <<-EOF $PROGNAME: replace files in one dir with files from another, but keeping the extension Synposis: $PROGNAME [-h|-s DIR] -h show this help and exit -s the source directory from which to pick files. Default: ./$SRC_DIR EOF } # Preamble -------------------------------------------------------------------- PROGNAME="$(basename "$0")" # halt script on any uncaught error set -e # the default directory SRC_DIR="temp" # parse arguments while getopts "hs:" OPTION; do case $OPTION in h) usage; exit 0 ;; s) SRC_DIR="$OPTARG" ;; *) die "Unknown option '$OPTION'" ;; esac done # input sanitisation [ -d "$SRC_DIR" ] || die "'$SRC_DIR' is not a directory or does not exist." [ "$(readlink -m "$SRC_DIR")" = "$(readlink -m .)" ] && die 'Source dir equals destination dir.' # generate list of possible destination files declare -A DST_FILES for DST_FILE in *; do [ -f "$DST_FILE" ] || continue DST_FILES["$DST_FILE"]='' done # Main part ------------------------------------------------------------------- # loop over all files in the source dir for SRC_PATH in "$SRC_DIR"/*; do [ "$SRC_PATH" = "$SRC_DIR/*" ] && die 'Source dir is empty.' SRC_FILE="${SRC_PATH##*/}" # selection of destination file echo echo "Select destination for file '$SRC_FILE':" unset DST_FILE select DST_FILE in '[-skip-]' '[-keep as is-]' "${!DST_FILES[@]}"; do [ "$DST_FILE" ] && break done # don't do anything with the file if [ ! "$DST_FILE" ] || [ "$DST_FILE" = "[-skip-]" ]; then echo " Skipping '$SRC_FILE'" continue fi # move the file to destination without renaming if [ "$DST_FILE" = "[-keep as is-]" ]; then if [ -f "$SRC_FILE" ]; then echo -n "The file '$SRC_FILE' already exists. Overwrite? [y/N] " read INPUT if [ "$INPUT" != "y" ] && [ "$INPUT" != "Y" ]; then echo " Skipping '$SRC_FILE'" continue fi fi move "$SRC_PATH" "./$SRC_FILE" else # replace destination with source file SRC_EXT="${SRC_FILE##*.}" DST_BASE="${DST_FILE%.*}" NEW_DST_FILE="${DST_BASE}.${SRC_EXT}" if [ "$DST_FILE" != "$NEW_DST_FILE" ]; then echo " Removing '$DST_FILE'" rm -f "$DST_FILE" fi move "$SRC_PATH" "./$NEW_DST_FILE" # remove the destination file from future selections unset DST_FILES["$DST_FILE"] fi done --1TXAKe06dm1MiOrj-- --753m0jv3VStoXdeG Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEVbE9o2D2lE5fhoVsizG+tUDUMMoFAmN+BmMACgkQizG+tUDU MMqPNA/8DFiHJshn/sGBpDwUC4N4sLUj2qsZzfe+O/GCfMeMzosFGtDCW0r6lTGa Am2yR6FpZYQD1rY+2dyRM45ZuJm6XZqdlc0CkWDXhpuRQmZmbJTlFQafBaGTeITv M2CjA/5VcRJww4CRXYbQ2P0DNeWfHNaitgwJec4AWB5tpX3q7bLOcXDk2T9Xta86 SgeHvbELqdlXueHnYE8wMjCidF+aU/65kveqPeWJlgLawkyrYBbaDA261sooICKU q7XrWZ8/iGbh7DFAnSkO48yATvTokHuX+EdJ61EgxAPbJVNxhx2SrdSAO3xpEmRa 79eB7Ewo/dL7nmWyPozzWrscBlrbMzvU0x84ncdax1feQqmTGcbqm5rYRsZ9bAec bq7BjtlqjYqhXSPsghMwJH5G6JeIVMaso2ti3HAp5s+JhY21OdzKIwjmtYM7iHno P6vDqK0o1xuSAYKvYD61Hyx0AErCEM1nSMt3yj/rNk78SqU/tZox/ylJmw4YHdZw 23tT0ijAhSH2TkRhoGwI+gEnJ7lZko82WpnbnLfhPMLQQm28H8SDKTfXgI3GavkR 7UNFaVyjKgM6VYGGDyVstkcUoMYenEVl1uJ4Ps8T7ecQ3avdyAYkKImxB6/3agSM yu+mLPVedl9PSFzJl9odCZHo25i5aVPd3VyyPfV7aUzDXEeksbU= =7ORA -----END PGP SIGNATURE----- --753m0jv3VStoXdeG--