bugreport: the %f macro

  • From: Liviu Andronic <landronimirc@xxxxxxxxx>
  • To: emelfm2@xxxxxxxxxxxxx
  • Date: Mon, 6 Feb 2006 10:32:47 +0100

I want to personalize the Remove spaces command. This is what I have:
>mv %f `echo %f | sed -e 's/ /_/g'`

When I mv a single file, it is OK. If I do it on multiple, this is what  I
get:
sh>mv "test file 07" "test file 08" `echo "test file 07" "test file 08" |
sed -e 's/ /_/g'` (3716)
mv: when moving multiple files, last argument must be a directory
Try `mv --help' for more information.
>mv "test file 07" "test file 08" `echo "test file 07" "test file 08" | sed
-e 's/ /_/g'` (3716) returned '1'

I change to the following:
>mv --target-directory=%d %f `echo %f | sed -e 's/ /_/g'`

And this is the error that I get:
sh>mv --target-directory="/home/liviu/test_base/" "test file 07" "test file
08" `echo "test file 07" "test file 08" | sed -e 's/ /_/g'` (3724)
mv: `test file 07' and `/home/liviu/test_base/test file 07' are the same
file
mv: `test file 08' and `/home/liviu/test_base/test file 08' are the same
file
mv: cannot stat `test_file_07_test_file_08': No such file or directory
>mv --target-directory="/home/liviu/test_base/" "test file 07" "test file
08" `echo "test file 07" "test file 08" | sed -e 's/ /_/g'` (3724) returned
'1'

For single file I get this:
sh>mv --target-directory="/home/liviu/test_base/" "test file 08" `echo "test
file 08" | sed -e 's/ /_/g'` (3729)
mv: `test file 08' and `/home/liviu/test_base/test file 08' are the same
file
mv: cannot stat `test_file_08': No such file or directory
>mv --target-directory="/home/liviu/test_base/" "test file 08" `echo "test
file 08" | sed -e 's/ /_/g'` (3729) returned '1'

Here I am beaten. I do not know whether it is linked to mv or to e2. Is
there any workaround for make it work for multiple files?
*18. Bug: if the file contains spaces, it refuses to move it. I think that
e2 forgets to make spaces correctly seen by the shell and that bash takes
the whole command as a multiple file rename.
sh>mv "test file 08" `echo "test file 08" | sed -e 's/test/folder/g'`
2>/dev/null (3739)
>mv "test file 08" `echo "test file 08" | sed -e 's/test/folder/g'`
2>/dev/null (3739) returned '1'

sh>mv "test_file_07" `echo "test_file_07" | sed -e 's/file/folder/g'`
2>/dev/null (3744)
>mv "test_file_07" `echo "test_file_07" | sed -e 's/file/folder/g'`
2>/dev/null (3744) returned '0'

Other related posts: