[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gcmd-usr] Passing multiple file pathes to shell scripts
From: |
mi |
Subject: |
Re: [gcmd-usr] Passing multiple file pathes to shell scripts |
Date: |
Tue, 12 Jul 2022 18:39:06 +0200 |
I setup these files:
file one.mp4 # one whitespace
file two.mp4 # two whitespaces
file three .mp4 # three whitespaces plus one before the suffix
This works when invoked from shell, but not with gcmd:
files="$@"
basedir=`pwd`
targetdir=$basedir/New_Folder/
mkdir $targetdir
#
alias message='zenity --info --text'
#
files=$(printf '%s' "$files" | sed 's/\.mp4/\.mp4\\n/g')
message "$files"
echo -e "$files" | grep -vx "" | while read file; do
message "$file"
mv "$file" $targetdir
done
Note: Uses the tool (installable package) 'zenity' for X feedback.
It's difficult to print correct X feedback since many print commands or tools
mangle whitespaces in complicated ways and it then gets unpredictable what
exactly ends up with the 'mv' command. Maybe it's safer to print debug info
into file but i didn't try that.