Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Sometimes wget picks up extra parameters when downloading a file, example Aev264-yale_econ2521120.m4v?bri=40.1&brs=689.

Obviously all I want is Aev264-yale_econ2521120.m4v.

I've poked through the man pages and can't see anything that stands out that would fix this. Any ideas?

share|improve this question
up vote 3 down vote accepted

If you're downloading one file at a time, you can use the -O option, which acts kind of like a shell redirection for the downloaded data.

Otherwise, this bash snippet should take care of fixing up the filenames afterwards:

for f in *\?*; do
    mv "$f" "${f%%\?*}"
share|improve this answer

As a more general solution, the venerable rename script works nicely:

 $ rename 's/m4v.*$/m4v/' Aev264*.m4v*

I'm pretty sure it is already installed in /usr/bin on debian/ubuntu/mint distributions and is a 42 line script if it isn't installed (well actually it's perl, so it's only one line if you're not into the whole readability thing).

$ squish /usr/bin/rename
use strict; use Getopt::Long; Getopt::Long::Configure('bundling'); my ($verbose, $no_act, $force, $op); die "Usage: rename [-v] [-n] [-f] perlexpr [filenames]\n" unless GetOptions( 'v|verbose' => \$verbose, 'n|no-act' => \$no_act, 'f|force' => \$force, ) and $op = shift; $verbose++ if $no_act; if (!@ARGV) { print "reading filenames from STDIN\n" if $verbose; @ARGV = <STDIN>; chop(@ARGV); } for (@ARGV) { my $was = $_; eval $op; die $@ if $@; next if $was eq $_; if (-e $_ and !$force) { warn "$was not renamed: $_ already exists\n"; } elsif ($no_act or rename $was, $_) { print "$was renamed as $_\n" if $verbose; } else { warn "Can't rename $was $_: $!\n"; } }
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.