>>> green = [[0.01775, 274903], [0.0177, 2767608], [0.01765, 1966445], [0.0176, 698199], [0.01755, 2853585], [0.0175, 944079], [0.01745, 2813977], [0.0174, 336701], [0.01735, 2118072], [0.0173, 975570]]
>>> max(green, key=lambda x: x[1])
[0.01755, 2853585]
fclones group -f json -o duplicates.json /путь
{
"header": {
"version": "0.27.3",
"timestamp": "2022-09-15T19:14:53.719409270+03:00",
"command": [
"/snap/fclones/19/bin/fclones",
"group",
"-f",
"json",
"."
],
"base_dir": "/root/clones",
"stats": {
"group_count": 2,
"total_file_count": 4,
"total_file_size": 1256780,
"redundant_file_count": 2,
"redundant_file_size": 628390,
"missing_file_count": 0,
"missing_file_size": 0
}
},
"groups": [
{
"file_len": 497684,
"file_hash": "3181bc6f0fecd38df0199d60e1189ba7",
"files": [
"/root/clones/IMG_20181016_045456 (copy).jpg",
"/root/clones/IMG_20181016_045456.jpg"
]
},
{
"file_len": 130706,
"file_hash": "5836d61ea4da8a05efb3870bdeed4028",
"files": [
"/root/clones/b3904388-decb-47b7-920c-36208ab8c201 (copy).jpg",
"/root/clones/b3904388-decb-47b7-920c-36208ab8c201.jpg"
]
}
]
}
import os
import json
import shutil
source_data = 'd.json' # исходный JSON
dest = 'duplicates' # директория назначения
with open(source_data, 'r') as data:
dup = json.loads(data.read())
duplicates = []
for group in dup['groups']:
for file in group['files']:
duplicates.append(file)
for file in duplicates:
if os.path.isfile(file):
shutil.move(file, dest)
CREATE TABLE IF NOT EXISTS ...
#!/usr/bin/env bash
my_cmd_1() {
echo "1st command output. Args: $*"
}
my_cmd_2() {
echo "2nd command output. Args: $*"
}
echo 'Available commands: my_cmd_1, my_cmd_2, exit'
while true; do
read -erp '>>> '
$REPLY
if [[ "$REPLY" == "exit" ]]; then
break
fi
done
~ $ ./cmd.sh
Available commands: my_cmd_1, my_cmd_2, exit
>>> my_cmd_1 --option argument
1st command output. Args: --option argument
>>> exit
read --help
man readline
#!/usr/bin/env bash
addr=google.com
lock=/tmp/connect.failed
while true; do
if ping -c 1 -W 5 "$addr" &> /dev/null; then
if [ -f "$lock" ]; then
notify-send 'Проверка подключения' 'Есть коннект'
rm "$lock"
fi
else
if [ ! -f "$lock" ]; then
notify-send 'Проверка подключения' 'Связи нет'
touch "$lock"
fi
fi
sleep 60
done
#!/bin/sh
dir=/mnt/d/Downloads
find "$dir" -type f -regextype egrep -regex '.*\.(mkv|m4v|mp4|ts|avi)' -print0 | sort -zr | xargs -0 -I {} echo {}
find "$dir" -type f -regextype egrep -regex '.*\.(flac|m4a|ape)' -print0 | sort -zr | xargs -0 -I {} echo {}
find "$dir" -type f -regextype egrep -regex '.*\.cue' -print0 | sort -zr | xargs -0 -I {} echo {}
Вместо echo вставьте свою команду. Вместо парных фигурных скобок подставляется имя файла. Если над файлами надо делать сложные действия, то можно сделать по аналогии:#!/bin/sh
dir=/mnt/d/Downloads
videos="$(find "$dir" -type f -regextype egrep -regex '.*\.(mkv|m4v|mp4|ts|avi)' | sort -r)"
if [ -n "$videos" ]; then
x=$IFS; IFS=$'\n';
for video in "$videos"; do
# делаем что-то
echo "$video"
done
IFS="$x"
fi