Move files to directories based on extension

后端 未结 6 1473
慢半拍i
慢半拍i 2020-12-14 02:06

I am new to Linux. I am trying to write a shell script which will move files to certain folders based on their extension, like for example in my downloads f

6条回答
  •  遥遥无期
    2020-12-14 02:23

    Two ways:

    1. find . -name '*mp3' -or -name '*ogg' -print | xargs -J% mv % ../../Music
    2. find . -name '*mp3' -or -name '*ogg' -exec mv {} ../Music \;

    The first uses a pipe and may run out of argument space; while the second may use too many forks and be slower. But, both will work.

提交回复
热议问题