Skip to main content
link to cas answer
Source Link
markgraf
  • 2.9k
  • 1
  • 10
  • 20

You are almost there:

Instead of mv video.mp4 VIDFOLDER you need to mv video.mp4 "$VIDFOLDER". The $ is needed to use the variable. It must NOT be used during assignement of the variable.

export VIDFOLDER=/path/to/my/folder should go into your .bashrc-file.

As an alternative, you could set up function for that (in .bashrc or .bash_aliases):

vidmv () {
  local videos="${@?need a file, please!}"
  local vidfolder=/path/to/my/folder

  for video in $videos ; do
    if [ -r "$video" ] ; then
      mv "$video" "$vidfolder"
    else
      printf '%s\n' "Can't read file \"$video\""
    fi
  done
}

and call that with vidmv somefile.mp4 or vidmv *.mp4 to move all .mp4 in, see the current directory.function provided by cas

You are almost there:

Instead of mv video.mp4 VIDFOLDER you need to mv video.mp4 "$VIDFOLDER". The $ is needed to use the variable. It must NOT be used during assignement of the variable.

export VIDFOLDER=/path/to/my/folder should go into your .bashrc-file.

As an alternative, you could set up function for that (in .bashrc or .bash_aliases):

vidmv () {
  local videos="${@?need a file, please!}"
  local vidfolder=/path/to/my/folder

  for video in $videos ; do
    if [ -r "$video" ] ; then
      mv "$video" "$vidfolder"
    else
      printf '%s\n' "Can't read file \"$video\""
    fi
  done
}

and call that with vidmv somefile.mp4 or vidmv *.mp4 to move all .mp4 in the current directory.

You are almost there:

Instead of mv video.mp4 VIDFOLDER you need to mv video.mp4 "$VIDFOLDER". The $ is needed to use the variable. It must NOT be used during assignement of the variable.

export VIDFOLDER=/path/to/my/folder should go into your .bashrc-file.

As an alternative, you could set up function for that (in .bashrc or .bash_aliases), see the function provided by cas

exporting VIDFOLDER
Source Link
markgraf
  • 2.9k
  • 1
  • 10
  • 20

You are almost there:

Instead of mv video.mp4 VIDFOLDER you need to mv video.mp4 "$VIDFOLDER". The $ is needed to use the variable. It must NOT be used during assignement of the variable.

And the export VIDFOLDER=/path/to/my/folder should go into your .bashrc-file.

As an alternative, you could set up function for that (in .bashrc or .bash_aliases):

vidmv () {
  local video="$videos="${1@?need a file, please!}" 
  local VIDFOLDER=$HOMEvidfolder=/temppath/videosto/my/folder

  for video in $videos ; do
    if [ -r "$video" ] ; then
      mv "$video" "$VIDFOLDER""$vidfolder"
    else
      printf '%s\n' "Can't read file \"$video\""
    fi
  done
}

and call that with vidmv somefile.mp4 or vidmv *.mp4 to move all .mp4 in the current directory.

You are almost there:

Instead of mv video.mp4 VIDFOLDER you need to mv video.mp4 "$VIDFOLDER". The $ is needed to use the variable. It must NOT be used during assignement of the variable.

And the VIDFOLDER=/path/to/my/folder should go into your .bashrc-file.

As an alternative, you could set up function for that (in .bashrc or .bash_aliases):

vidmv () {
  local video="${1?need a file, please!}" 
  local VIDFOLDER=$HOME/temp/videos

  if [ -r "$video" ] ; then
    mv "$video" "$VIDFOLDER"
  else
    printf '%s\n' "Can't read file \"$video\""
  fi
}

and call that with vidmv somefile.mp4

You are almost there:

Instead of mv video.mp4 VIDFOLDER you need to mv video.mp4 "$VIDFOLDER". The $ is needed to use the variable. It must NOT be used during assignement of the variable.

export VIDFOLDER=/path/to/my/folder should go into your .bashrc-file.

As an alternative, you could set up function for that (in .bashrc or .bash_aliases):

vidmv () {
  local videos="${@?need a file, please!}"
  local vidfolder=/path/to/my/folder

  for video in $videos ; do
    if [ -r "$video" ] ; then
      mv "$video" "$vidfolder"
    else
      printf '%s\n' "Can't read file \"$video\""
    fi
  done
}

and call that with vidmv somefile.mp4 or vidmv *.mp4 to move all .mp4 in the current directory.

sanity check
Source Link
markgraf
  • 2.9k
  • 1
  • 10
  • 20

You are almost there:

Instead of mv video.mp4 VIDFOLDER you need to mv video.mp4 "$VIDFOLDER". The $ is needed to use the variable. It must NOT be used during assignement of the variable.

And the VIDFOLDER=/path/to/my/folder should go into your .bashrc-file.

As an alternative, you could set up function for that (in .bashrc or .bash_aliases):

vidmv () {
  local video="${1?need a file, please!}" VIDFOLDER=/path/to
  local VIDFOLDER=$HOME/mytemp/foldervideos

  if [ ! -r "$video" ] ; then
    mv "$video" "$VIDFOLDER"
  else
    printf '%s''%s\n' "Can't read file \"$video\""
fi

mv "$video" "$VIDFOLDER"
fi
}

and call that with vidmv somefile.mp4

You are almost there:

Instead of mv video.mp4 VIDFOLDER you need to mv video.mp4 "$VIDFOLDER". The $ is needed to use the variable. It must NOT be used during assignement of the variable.

And the VIDFOLDER=/path/to/my/folder should go into your .bashrc-file.

As an alternative, you could set up function for that (in .bashrc or .bash_aliases):

vidmv () {
local video="${1?need a file, please!}" VIDFOLDER=/path/to/my/folder

if [ ! -r "$video" ] ; then
  printf '%s' "Can't read file \"$video\""
fi

mv "$video" "$VIDFOLDER"

}

and call that with vidmv somefile.mp4

You are almost there:

Instead of mv video.mp4 VIDFOLDER you need to mv video.mp4 "$VIDFOLDER". The $ is needed to use the variable. It must NOT be used during assignement of the variable.

And the VIDFOLDER=/path/to/my/folder should go into your .bashrc-file.

As an alternative, you could set up function for that (in .bashrc or .bash_aliases):

vidmv () {
  local video="${1?need a file, please!}" 
  local VIDFOLDER=$HOME/temp/videos

  if [ -r "$video" ] ; then
    mv "$video" "$VIDFOLDER"
  else
    printf '%s\n' "Can't read file \"$video\""
  fi
}

and call that with vidmv somefile.mp4

quoting vars
Source Link
markgraf
  • 2.9k
  • 1
  • 10
  • 20
Loading
Source Link
markgraf
  • 2.9k
  • 1
  • 10
  • 20
Loading