I have a script that first move the selected files into a temp directory,scans the directory, takes the largest file and create a new directory with that name, and moving all files to the newly created directory.
but it's crashing when bumping into directories or files containing the ' character, for example the word we're I think it can have something to do with the jfilenameall isn't "quoted" right, and I have tested a few ways, but haven't got it to work.
anybody that knows what I'm doing wrong?
Worth mention is that I'm running this script Via nemo action, so the following command line is executed:
script.sh "path/filename1.txt" "path/filename2.txt"
..and so on depending on how many files that was selected in the gui
jdir2="$1"
jdirfirst="${jdir2%/*}"
jdir="$jdirfirst"/
jdir0="$jdirfirst"
tmpdir="$jdir0/tmp.tmp3"
mkdir "$tmpdir"
mv "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$tmpdir"/
jfilenameall=$(basename $(find $tmpdir -maxdepth 1 -type f -printf "%s\t%p\n" | sort -n | tail -1 | awk '{print $NF}'))
jfilename="${jfilenameall::-4}"
jfilenameextension="$(echo -n $jfilenameall | tail -c 3)"
jfilename=${jdirlast::-4}
mkdir "$jdir0/$jfilename"
mv "$jdir0/tmp.tmp3/"* "$jdir0/$jfilename/"
$(find ...)
part like thisjfilenameall=$(basename "$(find ... )")
. Does that help? Anyways, you're command will also have problems with spaces in filenames like in "we are" to stay with your example ;-) – pLumo Sep 15 '20 at 7:33