Check out the errors:
Code:
#/bin/bash
for file in "$@"
do
if [[ -f "$file" ]]
then
new="${file%.*}"
if [[ "$file" == "$new" ]]
then
new="$new.dir"
fi
mkdir -- "$new"
fi
done > out.err.log 2>&1
this will create a log file (out.err.log) in the directory where the files are. Please post its content.
EDIT: Just tried it out and it works for me with 1 or more files.
I guess you also want to move the files to the newly created directory:
Code:
#!/bin/bash
shopt -s nullglob
for file
do
if [[ -f "$file" ]]
then
new="${file%.*}"
if [[ "$file" == "$new" ]]
then
new="$new.dir"
fi
mkdir -p -- "$new" || continue
mv -b -S '.backup' -- "$file" "$new"
fi
done
Bookmarks