Re: Bash Script to move Files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thom Paine wrote:

The example I was starting with was:

find -name *.tmp -exec rm -rf {} \;

And I tried to get it to seek out all my *.ogg files and dump them into a media folder.

like:

find . -name '*.ogg' -exec mv {} /media/oggs \;

To prevent it from moving files repeatedly, I changed to the directory I wanted to search and moved it to a different directory on another mount.

It won't move anything repeatedly, but it'll over write files with the same name. It'll also move directories, if their name ends in ".ogg"

I can't get it to work though. I thought I could substitute rm -rf with mv /media/oggs but that didn't seem to work.

The name of the file that matches the contstraints you described to "find" is substituted for the {} after -exec. Since mv expects the source before the destination, you'd need to use "mv {} /destination"


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux