added nautilus scripts (needs nautilus-python package)
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Source the script 'common-functions.sh'.
|
||||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||
ROOT_DIR=$(grep --only-matching "^.*scripts[^/]*" <<<"$SCRIPT_DIR")
|
||||
source "$ROOT_DIR/common-functions.sh"
|
||||
|
||||
_main() {
|
||||
local input_files=""
|
||||
local output_dir=""
|
||||
|
||||
# Execute initial checks.
|
||||
_check_dependencies ""
|
||||
_display_wait_box "2"
|
||||
input_files=$(_get_files "par_type=file; par_select_mime='text/|application/json'")
|
||||
output_dir=$(_get_output_dir "par_use_same_dir=false")
|
||||
|
||||
# Execute the function '_main_task' for each file in parallel.
|
||||
_run_task_parallel "$input_files" "$output_dir"
|
||||
_display_result_box "$output_dir"
|
||||
}
|
||||
|
||||
_main_task() {
|
||||
local input_file=$1
|
||||
local output_dir=$2
|
||||
local output_file=""
|
||||
local std_output=""
|
||||
local temp_file=""
|
||||
|
||||
# Work on a temporary file.
|
||||
temp_file=$(_get_temp_file)
|
||||
|
||||
# Run the main process.
|
||||
std_output=$(unexpand --tabs=4 -- "$input_file" >"$temp_file")
|
||||
_check_output "$?" "$std_output" "$input_file" "$output_file" || return 1
|
||||
|
||||
# Move the temporary file to the output.
|
||||
output_file=$(_get_output_filename "$input_file" "$output_dir" "par_extension_opt=preserve")
|
||||
_move_temp_file_to_output "$input_file" "$temp_file" "$output_file"
|
||||
|
||||
# Remove the temporary files on each iteration (if not removed before).
|
||||
rm -f -- "$temp_file"
|
||||
}
|
||||
|
||||
_main "$@"
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Source the script 'common-functions.sh'.
|
||||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||
ROOT_DIR=$(grep --only-matching "^.*scripts[^/]*" <<<"$SCRIPT_DIR")
|
||||
source "$ROOT_DIR/common-functions.sh"
|
||||
|
||||
_main() {
|
||||
local input_files=""
|
||||
local output_dir=""
|
||||
|
||||
# Execute initial checks.
|
||||
_check_dependencies ""
|
||||
_display_wait_box "2"
|
||||
input_files=$(_get_files "par_type=file; par_select_mime='text/|application/json'")
|
||||
output_dir=$(_get_output_dir "par_use_same_dir=false")
|
||||
|
||||
# Execute the function '_main_task' for each file in parallel.
|
||||
_run_task_parallel "$input_files" "$output_dir"
|
||||
_display_result_box "$output_dir"
|
||||
}
|
||||
|
||||
_main_task() {
|
||||
local input_file=$1
|
||||
local output_dir=$2
|
||||
local output_file=""
|
||||
local std_output=""
|
||||
local temp_file=""
|
||||
|
||||
# Work on a temporary file.
|
||||
temp_file=$(_get_temp_file)
|
||||
|
||||
# Run the main process.
|
||||
std_output=$(expand --tabs=4 -- "$input_file" >"$temp_file")
|
||||
_check_output "$?" "$std_output" "$input_file" "$output_file" || return 1
|
||||
|
||||
# Move the temporary file to the output.
|
||||
output_file=$(_get_output_filename "$input_file" "$output_dir" "par_extension_opt=preserve")
|
||||
_move_temp_file_to_output "$input_file" "$temp_file" "$output_file"
|
||||
|
||||
# Remove the temporary files on each iteration (if not removed before).
|
||||
rm -f -- "$temp_file"
|
||||
}
|
||||
|
||||
_main "$@"
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Source the script 'common-functions.sh'.
|
||||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||
ROOT_DIR=$(grep --only-matching "^.*scripts[^/]*" <<<"$SCRIPT_DIR")
|
||||
source "$ROOT_DIR/common-functions.sh"
|
||||
|
||||
_main() {
|
||||
local input_files=""
|
||||
local output_dir=""
|
||||
|
||||
# Execute initial checks.
|
||||
_check_dependencies "command=iconv; package=libc-bin"
|
||||
_display_wait_box "2"
|
||||
input_files=$(_get_files "par_type=file; par_select_mime='text/|application/json'")
|
||||
output_dir=$(_get_output_dir "par_use_same_dir=false")
|
||||
|
||||
# Execute the function '_main_task' for each file in parallel.
|
||||
_run_task_parallel "$input_files" "$output_dir"
|
||||
_display_result_box "$output_dir"
|
||||
}
|
||||
|
||||
_main_task() {
|
||||
local input_file=$1
|
||||
local output_dir=$2
|
||||
local output_file=""
|
||||
local std_output=""
|
||||
local temp_file=""
|
||||
|
||||
# Work on a temporary file.
|
||||
temp_file=$(_get_temp_file)
|
||||
|
||||
# Run the main process.
|
||||
std_output=$(iconv -f "$(_get_file_encoding "$input_file")" "$input_file" -t ascii//TRANSLIT -o "$temp_file")
|
||||
_check_output "$?" "$std_output" "$input_file" "$output_file" || return 1
|
||||
|
||||
# Move the temporary file to the output.
|
||||
output_file=$(_get_output_filename "$input_file" "$output_dir" "par_extension_opt=preserve")
|
||||
_move_temp_file_to_output "$input_file" "$temp_file" "$output_file"
|
||||
|
||||
# Remove the temporary files on each iteration (if not removed before).
|
||||
rm -f -- "$temp_file"
|
||||
}
|
||||
|
||||
_main "$@"
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Source the script 'common-functions.sh'.
|
||||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||
ROOT_DIR=$(grep --only-matching "^.*scripts[^/]*" <<<"$SCRIPT_DIR")
|
||||
source "$ROOT_DIR/common-functions.sh"
|
||||
|
||||
_main() {
|
||||
local input_files=""
|
||||
local output_dir=""
|
||||
|
||||
# Execute initial checks.
|
||||
_check_dependencies "command=iconv; package=libc-bin"
|
||||
_display_wait_box "2"
|
||||
input_files=$(_get_files "par_type=file; par_select_mime='text/|application/json'")
|
||||
output_dir=$(_get_output_dir "par_use_same_dir=false")
|
||||
|
||||
# Execute the function '_main_task' for each file in parallel.
|
||||
_run_task_parallel "$input_files" "$output_dir"
|
||||
_display_result_box "$output_dir"
|
||||
}
|
||||
|
||||
_main_task() {
|
||||
local input_file=$1
|
||||
local output_dir=$2
|
||||
local output_file=""
|
||||
local std_output=""
|
||||
local temp_file=""
|
||||
|
||||
# Work on a temporary file.
|
||||
temp_file=$(_get_temp_file)
|
||||
|
||||
# Run the main process.
|
||||
std_output=$(iconv -f "$(_get_file_encoding "$input_file")" "$input_file" -t iso-8859-1 -o "$temp_file")
|
||||
_check_output "$?" "$std_output" "$input_file" "" || return 1
|
||||
|
||||
# Move the temporary file to the output.
|
||||
output_file=$(_get_output_filename "$input_file" "$output_dir" "par_extension_opt=preserve")
|
||||
_move_temp_file_to_output "$input_file" "$temp_file" "$output_file"
|
||||
|
||||
# Remove the temporary files on each iteration (if not removed before).
|
||||
rm -f -- "$temp_file"
|
||||
}
|
||||
|
||||
_main "$@"
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Source the script 'common-functions.sh'.
|
||||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||
ROOT_DIR=$(grep --only-matching "^.*scripts[^/]*" <<<"$SCRIPT_DIR")
|
||||
source "$ROOT_DIR/common-functions.sh"
|
||||
|
||||
_main() {
|
||||
local input_files=""
|
||||
local output_dir=""
|
||||
|
||||
# Execute initial checks.
|
||||
_check_dependencies "command=iconv; package=libc-bin"
|
||||
_display_wait_box "2"
|
||||
input_files=$(_get_files "par_type=file; par_select_mime='text/|application/json'")
|
||||
output_dir=$(_get_output_dir "par_use_same_dir=false")
|
||||
|
||||
# Execute the function '_main_task' for each file in parallel.
|
||||
_run_task_parallel "$input_files" "$output_dir"
|
||||
_display_result_box "$output_dir"
|
||||
}
|
||||
|
||||
_main_task() {
|
||||
local input_file=$1
|
||||
local output_dir=$2
|
||||
local output_file=""
|
||||
local std_output=""
|
||||
local temp_file=""
|
||||
|
||||
# Work on a temporary file.
|
||||
temp_file=$(_get_temp_file)
|
||||
|
||||
# Run the main process.
|
||||
std_output=$(iconv -f "$(_get_file_encoding "$input_file")" "$input_file" -t utf-8 -o "$temp_file")
|
||||
_check_output "$?" "$std_output" "$input_file" "$output_file" || return 1
|
||||
|
||||
# Move the temporary file to the output.
|
||||
output_file=$(_get_output_filename "$input_file" "$output_dir" "par_extension_opt=preserve")
|
||||
_move_temp_file_to_output "$input_file" "$temp_file" "$output_file"
|
||||
|
||||
# Remove the temporary files on each iteration (if not removed before).
|
||||
rm -f -- "$temp_file"
|
||||
}
|
||||
|
||||
_main "$@"
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Source the script 'common-functions.sh'.
|
||||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||
ROOT_DIR=$(grep --only-matching "^.*scripts[^/]*" <<<"$SCRIPT_DIR")
|
||||
source "$ROOT_DIR/common-functions.sh"
|
||||
|
||||
_main() {
|
||||
local input_files=""
|
||||
local output_dir=""
|
||||
|
||||
# Execute initial checks.
|
||||
_check_dependencies "command=perl; package=perl-base"
|
||||
_display_wait_box "2"
|
||||
input_files=$(_get_files "par_type=file; par_select_mime='text/|application/json'")
|
||||
output_dir=$(_get_output_dir "par_use_same_dir=false")
|
||||
|
||||
# Execute the function '_main_task' for each file in parallel.
|
||||
_run_task_parallel "$input_files" "$output_dir"
|
||||
_display_result_box "$output_dir"
|
||||
}
|
||||
|
||||
_main_task() {
|
||||
local input_file=$1
|
||||
local output_dir=$2
|
||||
local output_file=""
|
||||
local std_output=""
|
||||
local temp_file=""
|
||||
|
||||
# Work on a temporary file.
|
||||
temp_file=$(_get_temp_file)
|
||||
|
||||
# Run the main process.
|
||||
std_output=$(perl -pe "s/\r\n|\n|\r/\r\n/g" -- "$input_file" >"$temp_file")
|
||||
_check_output "$?" "$std_output" "$input_file" "$output_file" || return 1
|
||||
|
||||
# Move the temporary file to the output.
|
||||
output_file=$(_get_output_filename "$input_file" "$output_dir" "par_extension_opt=preserve")
|
||||
_move_temp_file_to_output "$input_file" "$temp_file" "$output_file"
|
||||
|
||||
# Remove the temporary files on each iteration (if not removed before).
|
||||
rm -f -- "$temp_file"
|
||||
}
|
||||
|
||||
_main "$@"
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Source the script 'common-functions.sh'.
|
||||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||
ROOT_DIR=$(grep --only-matching "^.*scripts[^/]*" <<<"$SCRIPT_DIR")
|
||||
source "$ROOT_DIR/common-functions.sh"
|
||||
|
||||
_main() {
|
||||
local input_files=""
|
||||
local output_dir=""
|
||||
|
||||
# Execute initial checks.
|
||||
_check_dependencies "command=perl; package=perl-base"
|
||||
_display_wait_box "2"
|
||||
input_files=$(_get_files "par_type=file; par_select_mime='text/|application/json'")
|
||||
output_dir=$(_get_output_dir "par_use_same_dir=false")
|
||||
|
||||
# Execute the function '_main_task' for each file in parallel.
|
||||
_run_task_parallel "$input_files" "$output_dir"
|
||||
_display_result_box "$output_dir"
|
||||
}
|
||||
|
||||
_main_task() {
|
||||
local input_file=$1
|
||||
local output_dir=$2
|
||||
local output_file=""
|
||||
local std_output=""
|
||||
local temp_file=""
|
||||
|
||||
# Work on a temporary file.
|
||||
temp_file=$(_get_temp_file)
|
||||
|
||||
# Run the main process.
|
||||
std_output=$(perl -pe "s/\r\n|\n|\r/\n/g" -- "$input_file" >"$temp_file")
|
||||
_check_output "$?" "$std_output" "$input_file" "$output_file" || return 1
|
||||
|
||||
# Move the temporary file to the output.
|
||||
output_file=$(_get_output_filename "$input_file" "$output_dir" "par_extension_opt=preserve")
|
||||
_move_temp_file_to_output "$input_file" "$temp_file" "$output_file"
|
||||
|
||||
# Remove the temporary files on each iteration (if not removed before).
|
||||
rm -f -- "$temp_file"
|
||||
}
|
||||
|
||||
_main "$@"
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
# install_keyboard_shortcut=<Control><Alt>4
|
||||
|
||||
# Source the script 'common-functions.sh'.
|
||||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||
ROOT_DIR=$(grep --only-matching "^.*scripts[^/]*" <<<"$SCRIPT_DIR")
|
||||
source "$ROOT_DIR/common-functions.sh"
|
||||
|
||||
_main() {
|
||||
local input_files=""
|
||||
local output_dir=""
|
||||
|
||||
# Execute initial checks.
|
||||
_check_dependencies ""
|
||||
_display_wait_box "2"
|
||||
input_files=$(_get_files "par_type=file; par_recursive=true; par_get_pwd=true; par_select_mime='text/|application/json'")
|
||||
|
||||
# Execute the function '_main_task' for each file in parallel.
|
||||
_run_task_parallel "$input_files" "$output_dir"
|
||||
|
||||
local std_output=""
|
||||
std_output=$(_storage_text_read_all)
|
||||
std_output=$(_text_sort "$std_output")
|
||||
|
||||
_display_list_box "$std_output" "--column=Encoding;--column=File"
|
||||
}
|
||||
|
||||
_main_task() {
|
||||
local input_file=$1
|
||||
local output_dir=$2
|
||||
local std_output=""
|
||||
local file_encoding=""
|
||||
file_encoding=$(_get_file_encoding "$input_file")
|
||||
|
||||
if [[ -z "$file_encoding" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# Run the main process.
|
||||
std_output="$file_encoding$FIELD_SEPARATOR$input_file"
|
||||
std_output=$(_text_remove_pwd "$std_output")
|
||||
|
||||
_storage_text_write_ln "$std_output"
|
||||
}
|
||||
|
||||
_main "$@"
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
# install_keyboard_shortcut=<Control><Alt>3
|
||||
|
||||
# Source the script 'common-functions.sh'.
|
||||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||
ROOT_DIR=$(grep --only-matching "^.*scripts[^/]*" <<<"$SCRIPT_DIR")
|
||||
source "$ROOT_DIR/common-functions.sh"
|
||||
|
||||
_main() {
|
||||
local input_files=""
|
||||
local output_dir=""
|
||||
|
||||
# Execute initial checks.
|
||||
_check_dependencies ""
|
||||
_display_wait_box "2"
|
||||
input_files=$(_get_files "par_type=file; par_recursive=true; par_get_pwd=true; par_select_mime='text/|application/json'")
|
||||
|
||||
# Execute the function '_main_task' for each file in parallel.
|
||||
_run_task_parallel "$input_files" "$output_dir"
|
||||
|
||||
local std_output=""
|
||||
std_output=$(_storage_text_read_all)
|
||||
|
||||
_display_list_box "$std_output" "--column=Char;--column=Line;--column=File"
|
||||
}
|
||||
|
||||
_main_task() {
|
||||
local input_file=$1
|
||||
local output_dir=$2
|
||||
local std_output=""
|
||||
|
||||
# Run the main process.
|
||||
std_output=$(
|
||||
grep --ignore-case --perl-regexp --only-matching --line-number \
|
||||
"[^ \w\t\n\r\-\,\;\:\!\?\.\'\"\(\)\[\]\{\}\@\*\/\\\&\#\%\`\^\+\<\=\>\|\~\$áàâãçéêíóôõú\“\”®§©ªº°¹²³«»´¢£µ]" \
|
||||
-- "$input_file" /dev/null
|
||||
)
|
||||
std_output=$(_text_remove_pwd "$std_output")
|
||||
# shellcheck disable=SC2001
|
||||
std_output=$(sed "s|^\([^:]*\):\([^:]*\):\([^:]*\)$|\3$FIELD_SEPARATOR\2$FIELD_SEPARATOR\1|g" <<<"$std_output")
|
||||
|
||||
_storage_text_write_ln "$std_output"
|
||||
}
|
||||
|
||||
_main "$@"
|
||||
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
# shellcheck disable=SC2001
|
||||
# install_keyboard_shortcut=<Control><Alt>5
|
||||
|
||||
# Source the script 'common-functions.sh'.
|
||||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||
ROOT_DIR=$(grep --only-matching "^.*scripts[^/]*" <<<"$SCRIPT_DIR")
|
||||
source "$ROOT_DIR/common-functions.sh"
|
||||
|
||||
_main() {
|
||||
local input_files=""
|
||||
local output_dir=""
|
||||
|
||||
# Execute initial checks.
|
||||
_check_dependencies ""
|
||||
_display_wait_box "2"
|
||||
input_files=$(_get_files "par_type=file; par_recursive=true; par_get_pwd=true; par_select_mime='text/|application/json'")
|
||||
|
||||
# Execute the function '_main_task' for each file in parallel.
|
||||
_run_task_parallel "$input_files" "$output_dir"
|
||||
|
||||
local std_output=""
|
||||
std_output=$(_storage_text_read_all)
|
||||
std_output=$(_text_sort "$std_output")
|
||||
|
||||
_display_list_box "$std_output" "--column=Endings;--column=File"
|
||||
}
|
||||
|
||||
_main_task() {
|
||||
local input_file=$1
|
||||
local output_dir=$2
|
||||
local std_output=""
|
||||
|
||||
# Run the main process.
|
||||
std_output=$(file --dereference --separator "$FIELD_SEPARATOR" --no-pad -- "$input_file")
|
||||
std_output=$(_text_remove_pwd "$std_output")
|
||||
std_output=$(sed "s|$FIELD_SEPARATOR.*with CRLF, CR, LF line.*|$FIELD_SEPARATOR CRLF+CR+LF (windows)|" <<<"$std_output")
|
||||
std_output=$(sed "s|$FIELD_SEPARATOR.*with CRLF, LF line.*|$FIELD_SEPARATOR CRLF+LF (windows)|" <<<"$std_output")
|
||||
std_output=$(sed "s|$FIELD_SEPARATOR.*with CRLF, CR line.*|$FIELD_SEPARATOR CRLF+CR (windows)|" <<<"$std_output")
|
||||
std_output=$(sed "s|$FIELD_SEPARATOR.*with CRLF line.*|$FIELD_SEPARATOR CRLF (windows)|" <<<"$std_output")
|
||||
std_output=$(sed "s|$FIELD_SEPARATOR.*with CR line.*|$FIELD_SEPARATOR CR (mac)|" <<<"$std_output")
|
||||
std_output=$(sed "s|$FIELD_SEPARATOR.*with CR, LF line.*|$FIELD_SEPARATOR CR+LF (mac)|" <<<"$std_output")
|
||||
std_output=$(sed "s|$FIELD_SEPARATOR.*no line.*|$FIELD_SEPARATOR (no line)|" <<<"$std_output")
|
||||
std_output=$(sed "s|$FIELD_SEPARATOR.*text.*|$FIELD_SEPARATOR LF (unix)|" <<<"$std_output")
|
||||
std_output=$(sed "s|\(.*\)$FIELD_SEPARATOR\s*\(.*\)|\2$FIELD_SEPARATOR\1|" <<<"$std_output")
|
||||
std_output=$(grep "(windows)\|(unix)\|(mac)\|(no line)" <<<"$std_output")
|
||||
|
||||
_storage_text_write_ln "$std_output"
|
||||
}
|
||||
|
||||
_main "$@"
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
# install_keyboard_shortcut=<Control><Alt>6
|
||||
|
||||
# Source the script 'common-functions.sh'.
|
||||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||
ROOT_DIR=$(grep --only-matching "^.*scripts[^/]*" <<<"$SCRIPT_DIR")
|
||||
source "$ROOT_DIR/common-functions.sh"
|
||||
|
||||
_main() {
|
||||
local input_files=""
|
||||
local output_dir=""
|
||||
|
||||
# Execute initial checks.
|
||||
_check_dependencies ""
|
||||
_display_wait_box "2"
|
||||
input_files=$(_get_files "par_type=file; par_recursive=true; par_get_pwd=true; par_select_mime='text/|application/json'")
|
||||
|
||||
# Execute the function '_main_task' for each file in parallel.
|
||||
_run_task_parallel "$input_files" "$output_dir"
|
||||
|
||||
local std_output=""
|
||||
std_output=$(_storage_text_read_all)
|
||||
std_output=$(sort -h -r <<<"$std_output")
|
||||
|
||||
_display_list_box "$std_output" "--column=Count;--column=File"
|
||||
}
|
||||
|
||||
_main_task() {
|
||||
local input_file=$1
|
||||
local output_dir=$2
|
||||
local std_output=""
|
||||
|
||||
# Run the main process.
|
||||
std_output=$(wc --lines -- "$input_file" 2>/dev/null)
|
||||
std_output=$(grep -v ".*[0-9]* total$" <<<"$std_output")
|
||||
# shellcheck disable=SC2001
|
||||
std_output=$(sed "s| *\([0-9]*\) *\(.*\)|\1$FIELD_SEPARATOR\2|" <<<"$std_output")
|
||||
std_output=$(_text_remove_pwd "$std_output")
|
||||
|
||||
_storage_text_write_ln "$std_output"
|
||||
}
|
||||
|
||||
_main "$@"
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
# install_keyboard_shortcut=<Control><Alt>7
|
||||
|
||||
# Source the script 'common-functions.sh'.
|
||||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||
ROOT_DIR=$(grep --only-matching "^.*scripts[^/]*" <<<"$SCRIPT_DIR")
|
||||
source "$ROOT_DIR/common-functions.sh"
|
||||
|
||||
_main() {
|
||||
local input_files=""
|
||||
local output_dir=""
|
||||
|
||||
# Execute initial checks.
|
||||
_check_dependencies ""
|
||||
_display_wait_box "2"
|
||||
input_files=$(_get_files "par_type=file; par_recursive=true; par_get_pwd=true; par_select_mime='text/|application/json'")
|
||||
|
||||
# Execute the function '_main_task' for each file in parallel.
|
||||
_run_task_parallel "$input_files" "$output_dir"
|
||||
|
||||
local std_output=""
|
||||
std_output=$(_storage_text_read_all)
|
||||
std_output=$(sort -h -r <<<"$std_output")
|
||||
|
||||
_display_list_box "$std_output" "--column=Count;--column=File"
|
||||
}
|
||||
|
||||
_main_task() {
|
||||
local input_file=$1
|
||||
local output_dir=$2
|
||||
local std_output=""
|
||||
|
||||
# Run the main process.
|
||||
std_output=$(wc --max-line-length -- "$input_file" 2>/dev/null)
|
||||
std_output=$(grep -v ".*[0-9]* total$" <<<"$std_output")
|
||||
# shellcheck disable=SC2001
|
||||
std_output=$(sed "s| *\([0-9]*\) *\(.*\)|\1$FIELD_SEPARATOR\2|" <<<"$std_output")
|
||||
std_output=$(_text_remove_pwd "$std_output")
|
||||
|
||||
_storage_text_write_ln "$std_output"
|
||||
}
|
||||
|
||||
_main "$@"
|
||||
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env bash
|
||||
# install_keyboard_shortcut=<Control><Alt>2
|
||||
|
||||
# Source the script 'common-functions.sh'.
|
||||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||
ROOT_DIR=$(grep --only-matching "^.*scripts[^/]*" <<<"$SCRIPT_DIR")
|
||||
source "$ROOT_DIR/common-functions.sh"
|
||||
|
||||
_main() {
|
||||
local input_files=""
|
||||
|
||||
# Execute initial checks.
|
||||
_check_dependencies ""
|
||||
_display_wait_box "2"
|
||||
input_files=$(_get_files "par_type=file; par_recursive=true; par_get_pwd=true; par_select_mime='text/|application/json'")
|
||||
|
||||
# Execute the function '_main_task' for each file in parallel.
|
||||
_run_task_parallel "$input_files" ""
|
||||
|
||||
local std_output=""
|
||||
std_output=$(_storage_text_read_all)
|
||||
std_output=$(_text_sort "$std_output")
|
||||
|
||||
_display_list_box "$std_output" "--column=Issues;--column=File"
|
||||
}
|
||||
|
||||
_main_task() {
|
||||
local input_file=$1
|
||||
local output_dir=$2
|
||||
local file_encoding=""
|
||||
local file_information=""
|
||||
local issues=""
|
||||
|
||||
file_encoding=$(_get_file_encoding "$input_file")
|
||||
file_information=$(file --dereference --separator "$FIELD_SEPARATOR" --no-pad -- "$input_file" | sed "s|\(.*\)$FIELD_SEPARATOR ||")
|
||||
|
||||
# Run the checker 'non UTF-8 encoding'.
|
||||
if [[ "${file_encoding,,}" != *"us-ascii"* ]] && [[ "${file_encoding,,}" != *"utf-8"* ]]; then
|
||||
issues+="[non UTF-8 encoding]"
|
||||
fi
|
||||
|
||||
# Run the checker 'UTF-8 with BOM'.
|
||||
if [[ "${file_encoding,,}" == *"utf-8"* ]]; then
|
||||
if head -c3 "$input_file" | LC_ALL=C grep --quiet --perl-regexp -m1 '\xef\xbb\xbf'; then
|
||||
issues+="[UTF-8 with BOM]"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run the checker 'non-LF line break'.
|
||||
if [[ "$file_information" == *"with CR"* ]]; then
|
||||
issues+="[non-LF line break]"
|
||||
fi
|
||||
|
||||
# Run the checker 'trailing spaces' (for Unix and Windows files).
|
||||
if grep --quiet --perl-regexp -m1 "[ \t]\r?$" "$input_file"; then
|
||||
issues+="[trailing spaces]"
|
||||
fi
|
||||
|
||||
# Run the checker 'trailing spaces' (for Mac files).
|
||||
if [[ "$file_information" == *"with CR line"* ]] || [[ "$file_information" == *"with CR, LF line"* ]]; then
|
||||
if cat -A "$input_file" | grep --quiet -m1 " ^M"; then
|
||||
[[ "$issues" != *"trailing spaces"* ]] && issues+="[trailing spaces]"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run the checker 'mix tabs and spaces' (different lines).
|
||||
if grep --quiet --perl-regexp -m1 "^\t" "$input_file" && grep --quiet --perl-regexp -m1 "^ " "$input_file"; then
|
||||
issues+="[mix tabs and spaces]"
|
||||
fi
|
||||
|
||||
# Run the checker 'mix tabs and spaces' (same line).
|
||||
if grep --quiet --perl-regexp -m1 "\t " "$input_file" || grep --quiet --perl-regexp -m1 " \t" "$input_file"; then
|
||||
[[ "$issues" != *"mix tabs and spaces"* ]] && issues+="[mix tabs and spaces]"
|
||||
fi
|
||||
|
||||
# Run the checker 'missing line at the end'.
|
||||
if ! tail -c 1 "$input_file" | hexdump -e '16/1 "%02x" "\n"' | grep --quiet -m1 "0d\|0a"; then
|
||||
issues+="[missing line at the end]"
|
||||
else
|
||||
if tail -c 3 "$input_file" | hexdump -e '16/1 "%02x" "\n"' | grep --quiet -m1 "..0d0d\|..0a0a\|0a0d0a"; then
|
||||
# Run the checker 'has many line breaks at the end'.
|
||||
issues+="[extra lines at the end]"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Save the result only for files with issues.
|
||||
if [[ -n "$issues" ]]; then
|
||||
_storage_text_write_ln "$issues$FIELD_SEPARATOR$(_text_remove_pwd "$input_file")"
|
||||
fi
|
||||
}
|
||||
|
||||
_main "$@"
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
# install_keyboard_shortcut=<Control><Alt>8
|
||||
|
||||
# Source the script 'common-functions.sh'.
|
||||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||
ROOT_DIR=$(grep --only-matching "^.*scripts[^/]*" <<<"$SCRIPT_DIR")
|
||||
source "$ROOT_DIR/common-functions.sh"
|
||||
|
||||
_main() {
|
||||
local input_files=""
|
||||
local output_dir=""
|
||||
|
||||
# Execute initial checks.
|
||||
_check_dependencies ""
|
||||
_display_wait_box "2"
|
||||
input_files=$(_get_files "par_type=file; par_recursive=true; par_get_pwd=true; par_select_mime='text/|application/json'")
|
||||
|
||||
# Execute the function '_main_task' for each file in parallel.
|
||||
_run_task_parallel "$input_files" "$output_dir"
|
||||
|
||||
local std_output=""
|
||||
std_output=$(_storage_text_read_all)
|
||||
std_output=$(sort -h -r <<<"$std_output")
|
||||
|
||||
_display_list_box "$std_output" "--column=Count;--column=File"
|
||||
}
|
||||
|
||||
_main_task() {
|
||||
local input_file=$1
|
||||
local output_dir=$2
|
||||
local std_output=""
|
||||
|
||||
# Run the main process.
|
||||
std_output=$(wc --words -- "$input_file" 2>/dev/null)
|
||||
std_output=$(grep -v ".*[0-9]* total$" <<<"$std_output")
|
||||
# shellcheck disable=SC2001
|
||||
std_output=$(sed "s| *\([0-9]*\) *\(.*\)|\1$FIELD_SEPARATOR\2|" <<<"$std_output")
|
||||
std_output=$(_text_remove_pwd "$std_output")
|
||||
|
||||
_storage_text_write_ln "$std_output"
|
||||
}
|
||||
|
||||
_main "$@"
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Source the script 'common-functions.sh'.
|
||||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||
ROOT_DIR=$(grep --only-matching "^.*scripts[^/]*" <<<"$SCRIPT_DIR")
|
||||
source "$ROOT_DIR/common-functions.sh"
|
||||
|
||||
_main() {
|
||||
local input_files=""
|
||||
local output_dir=""
|
||||
|
||||
# Execute initial checks.
|
||||
_check_dependencies ""
|
||||
_display_wait_box "2"
|
||||
input_files=$(_get_files "par_type=file; par_select_mime='text/|application/json'")
|
||||
output_dir=$(_get_output_dir "par_use_same_dir=false")
|
||||
|
||||
# Execute the function '_main_task' for each file in parallel.
|
||||
_run_task_parallel "$input_files" "$output_dir"
|
||||
_display_result_box "$output_dir"
|
||||
}
|
||||
|
||||
_main_task() {
|
||||
local input_file=$1
|
||||
local output_dir=$2
|
||||
local output_file=""
|
||||
local std_output=""
|
||||
local temp_file=""
|
||||
|
||||
# Work on a temporary file.
|
||||
temp_file=$(_get_temp_file)
|
||||
|
||||
# Run the main process.
|
||||
std_output=$(sed "s|[ \t]*\(\r*\)$|\1|" -- "$input_file" >"$temp_file")
|
||||
_check_output "$?" "$std_output" "$input_file" "$output_file" || return 1
|
||||
|
||||
# Move the temporary file to the output.
|
||||
output_file=$(_get_output_filename "$input_file" "$output_dir" "par_extension_opt=preserve")
|
||||
_move_temp_file_to_output "$input_file" "$temp_file" "$output_file"
|
||||
|
||||
# Remove the temporary files on each iteration (if not removed before).
|
||||
rm -f -- "$temp_file"
|
||||
}
|
||||
|
||||
_main "$@"
|
||||
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Source the script 'common-functions.sh'.
|
||||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||
ROOT_DIR=$(grep --only-matching "^.*scripts[^/]*" <<<"$SCRIPT_DIR")
|
||||
source "$ROOT_DIR/common-functions.sh"
|
||||
|
||||
_main() {
|
||||
local input_files=""
|
||||
local output_dir=""
|
||||
|
||||
# Execute initial checks.
|
||||
_check_dependencies "command=iconv; package=libc-bin | command=perl; package=perl-base"
|
||||
_display_wait_box "2"
|
||||
input_files=$(_get_files "par_type=file; par_recursive=true; par_select_mime='text/|application/json'; par_skip_extension=bak")
|
||||
|
||||
# Execute the function '_main_task' for each file in parallel.
|
||||
_run_task_parallel "$input_files" "$output_dir"
|
||||
_display_result_box ""
|
||||
}
|
||||
|
||||
_main_task() {
|
||||
local input_file=$1
|
||||
local output_dir=$2
|
||||
local output_file=""
|
||||
local std_output=""
|
||||
local temp_file1=""
|
||||
local temp_file2=""
|
||||
|
||||
# Work on a temporary file.
|
||||
temp_file1=$(_get_temp_file)
|
||||
temp_file2=$(_get_temp_file)
|
||||
|
||||
# Run the process (part 1) 'convert encoding to utf-8'.
|
||||
std_output=$(iconv -f "$(_get_file_encoding "$input_file")" "$input_file" -t utf-8 -o "$temp_file1")
|
||||
_check_output "$?" "$std_output" "$input_file" "" || return 1
|
||||
|
||||
# Run the process (part 2) 'convert line breaks to Windows'.
|
||||
std_output=$(perl -pe "s/\r\n|\n|\r/\r\n/g" "$temp_file1" >"$temp_file2")
|
||||
_check_output "$?" "$std_output" "$input_file" "" || return 1
|
||||
|
||||
# Run the process (part 3) 'remove trailing spaces'.
|
||||
sed -i "s|[ \t]*\(\r*\)$|\1|" "$temp_file2"
|
||||
|
||||
# Run the process (part 4) 'remove the empty line in EOF'.
|
||||
printf "\n" >>"$temp_file2"
|
||||
sed -i ':Loop;N;$!bLoop;s|\n*$||g' "$temp_file2"
|
||||
|
||||
# Move the temporary file to the output.
|
||||
output_file=$input_file
|
||||
_move_temp_file_to_output "$input_file" "$temp_file2" "$output_file"
|
||||
|
||||
# Remove the temporary files on each iteration (if not removed before).
|
||||
rm -f -- "$temp_file1"
|
||||
rm -f -- "$temp_file2"
|
||||
}
|
||||
|
||||
_main "$@"
|
||||
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Source the script 'common-functions.sh'.
|
||||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||
ROOT_DIR=$(grep --only-matching "^.*scripts[^/]*" <<<"$SCRIPT_DIR")
|
||||
source "$ROOT_DIR/common-functions.sh"
|
||||
|
||||
_main() {
|
||||
local input_files=""
|
||||
local output_dir=""
|
||||
|
||||
# Execute initial checks.
|
||||
_check_dependencies "command=iconv; package=libc-bin | command=perl; package=perl-base"
|
||||
_display_wait_box "2"
|
||||
input_files=$(_get_files "par_type=file; par_recursive=true; par_select_mime='text/|application/json'; par_skip_extension=bak")
|
||||
|
||||
# Execute the function '_main_task' for each file in parallel.
|
||||
_run_task_parallel "$input_files" "$output_dir"
|
||||
_display_result_box ""
|
||||
}
|
||||
|
||||
_main_task() {
|
||||
local input_file=$1
|
||||
local output_dir=$2
|
||||
local output_file=""
|
||||
local std_output=""
|
||||
local temp_file1=""
|
||||
local temp_file2=""
|
||||
|
||||
# Work on a temporary file.
|
||||
temp_file1=$(_get_temp_file)
|
||||
temp_file2=$(_get_temp_file)
|
||||
|
||||
# Run the process (part 1) 'convert encoding to utf-8'.
|
||||
std_output=$(iconv -f "$(_get_file_encoding "$input_file")" "$input_file" -t utf-8 -o "$temp_file1")
|
||||
_check_output "$?" "$std_output" "$input_file" "" || return 1
|
||||
|
||||
# Run the process (part 2) 'convert line breaks to Unix'.
|
||||
std_output=$(perl -pe "s/\r\n|\n|\r/\n/g" "$temp_file1" >"$temp_file2")
|
||||
_check_output "$?" "$std_output" "$input_file" "" || return 1
|
||||
|
||||
# Run the process (part 3) 'remove trailing spaces'.
|
||||
sed -i "s|[ \t]*\(\r*\)$|\1|" "$temp_file2"
|
||||
|
||||
# Run the process (part 4) 'remove the empty line in EOF'.
|
||||
printf "\n" >>"$temp_file2"
|
||||
sed -i ':Loop;N;$!bLoop;s|\n*$||g' "$temp_file2"
|
||||
|
||||
# Move the temporary file to the output.
|
||||
output_file=$input_file
|
||||
_move_temp_file_to_output "$input_file" "$temp_file2" "$output_file"
|
||||
|
||||
# Remove the temporary files on each iteration (if not removed before).
|
||||
rm -f -- "$temp_file1"
|
||||
rm -f -- "$temp_file2"
|
||||
}
|
||||
|
||||
_main "$@"
|
||||
Reference in New Issue
Block a user