fix shell hinting
This commit is contained in:
parent
c9ec93d456
commit
77cb1f013a
6 changed files with 41 additions and 14 deletions
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Default values
|
||||
VERBOSE=false
|
||||
|
|
@ -61,42 +61,42 @@ moved_count=0
|
|||
# Function to process files
|
||||
process_files() {
|
||||
local find_cmd="find \"$SOURCE_DIR\" -maxdepth 1 -type f -iname \"*$SEARCH_WORD*\""
|
||||
|
||||
|
||||
# Exclude .part files and macOS resource fork files by default
|
||||
if [ "$INCLUDE_PART" = false ]; then
|
||||
find_cmd="$find_cmd -not -name \"*.part\""
|
||||
fi
|
||||
find_cmd="$find_cmd -not -name \"._*\""
|
||||
|
||||
|
||||
# First, show what would be moved
|
||||
echo "The following files would be moved:"
|
||||
eval "$find_cmd"
|
||||
|
||||
|
||||
# Count files that would be moved
|
||||
local file_count=$(eval "$find_cmd" | wc -l)
|
||||
|
||||
|
||||
if [ "$file_count" -eq 0 ]; then
|
||||
echo "No matching files found."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# Show what actions will be taken
|
||||
echo
|
||||
if [ ! -d "$DEST_DIR" ]; then
|
||||
echo "The destination directory '$DEST_DIR' will be created."
|
||||
fi
|
||||
echo "Files will be moved to: '$DEST_DIR'"
|
||||
|
||||
|
||||
# Prompt for confirmation
|
||||
echo -n "Do you want to proceed? (y/n): "
|
||||
read -r response
|
||||
|
||||
|
||||
if [[ "$response" =~ ^[Yy]$ ]]; then
|
||||
# Create destination directory if needed
|
||||
if [ ! -d "$DEST_DIR" ]; then
|
||||
mkdir -p "$DEST_DIR"
|
||||
fi
|
||||
|
||||
|
||||
while IFS= read -r file; do
|
||||
if [ "$VERBOSE" = true ]; then
|
||||
echo "Moving: $file"
|
||||
|
|
@ -107,7 +107,7 @@ process_files() {
|
|||
echo "Error: Failed to move '$file'" >&2
|
||||
fi
|
||||
done < <(eval "$find_cmd")
|
||||
|
||||
|
||||
echo "Operation completed. $moved_count file(s) moved to '$DEST_DIR'"
|
||||
else
|
||||
echo "Operation cancelled."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue