You are not logged in.
Pages: 1
Hi all,
I want to rename all my ".folder.jpg" in my music folder (because banshee does not recognize them)
to "folder.jpg".
How can I do this from the command line? I know find and mv, but how to combine them?
Thanks alot.
Offline
EDIT: this doesn't work!!
Maybe something like this (untested):
find music -name '*jpg' -exec mv '{}' `dirname '{}'`/folder.jpg \;
Last edited by lessthanjake (2007-08-21 08:55:16)
Offline
Untested means either backup your music folder first, or change that command sightly, eg with mv -i .
For me, it moved all .folder.jpg to folder.jpg in the current working directory. So it seems to overwrite the files, letting you with only one.
pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))
Offline
Last one wouldn't work! But this shuould:
But as alway be careful when doing stuff like this, I would dryrun once with mv changed to echo or as mentioned with the -i flag on mv.
find musikk -name '*jpg' |while read f; do mv "$f" `dirname "$f"`/folder.jpg; done
Last edited by lessthanjake (2007-08-21 08:59:54)
Offline
That seems to work better. Just added "" that should make it work with dirnames containing space
find bla -name '.folder.jpg' |while read f; do mv -i "$f" "`dirname "$f"`"/folder.jpg; done
Last edited by shining (2007-08-21 09:13:16)
pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))
Offline
Surely someone has a better solution.
You write the following code in a file and execute it changing its mode in 755.
f=`find . -type f -name ".*" -print | cut -d. -f3`
for i in `echo $f`
do
mv .$i.jpg $i.jpg
done
Offline
Both versions work, thank you very much. (The commands work surprisingly fast although i have a large library)
Offline
Surely someone has a better solution.
You write the following code in a file and execute it changing its mode in 755.f=`find . -type f -name ".*" -print | cut -d. -f3` for i in `echo $f` do mv .$i.jpg $i.jpg done
I think this one would only work for files on the first level.
In this case, don't use find, but rather something like :
for i in .*.jpg; do mv $i ${i#.*}; done
pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))
Offline
morellik wrote:Surely someone has a better solution.
You write the following code in a file and execute it changing its mode in 755.f=`find . -type f -name ".*" -print | cut -d. -f3` for i in `echo $f` do mv .$i.jpg $i.jpg done
I think this one would only work for files on the first level.
In this case, don't use find, but rather something like :for i in .*.jpg; do mv $i ${i#.*}; done
Yes, of course. Thanks for the improvements.
Offline
Although you already have a solution, here's another option using mmv: http://aur.archlinux.org/packages.php?d … ns=&SeB=nd and http://linux.die.net/man/1/mmv. Don't know if that helps though but... good luck.
Micha
Offline
Pages: 1