Terminal For Loop; Move Multiple Files; Ubuntu

To move files using a for loop, do the following:

cd /path/to/files/directory
for i in *.txt; do mv $i ~/Desktop/destination/$i; done

The above code will move files with a txt extension to the destination folder on the desktop.

View this page on GitHub.
Posted .

4 comments

  1. anonymous

    Is there any specific reason you'd use that as opposed to

    mv *.txt ~/Desktop/destination/

    ?

  2. anonymous
    "Is there any specific reason you'd use that as opposed to mv *.txt ~/Desktop/destination/" for mv not really, but: cd path/to/scripts/ for i in *.sh; do bash $i; done
  3. anonymous

    Batch transcoding:

    #!/bin/bash

    vcodec="VIDEO_CODEC"

    acodec="AUDIO_CODEC"

    bitrate="VIDEO_BITRATE"

    arate="AUDIO_BITRATE"

    ext="OUTPUT_EXT"

    mux="MUXER"

    vlc="PATH_TO_VLC"

    fmt="INPUT_EXT"

    for a in *$fmt; do

    $vlc -I dummy -vvv "$a" --sout "#transcode{vcodec=$vcodec,vb=$bitrate,acodec=$acodec,ab=$arate,channels=6}:standard{mux=$mux,dst=\"$a.$ext\",access=file}"vlc://quit

    done

  4. anonymous

    how to arrange the curly brace and write some data under iy in another para

Leave a Reply