I tried to use the command:

mv *.1.gz.html *.html

But, I got the response:

<filename> is not a directory.

How can I get this working? I tried the rename command as well, but, I couldn't get that working either. Too much regex for me.

I think using xargs would work, if I understood that better.


2 Answers 2


mv either renames a single file or moves many files into a single directory.

If you want to rename many files you probably want to use rename.

Depending on your version of rename you do:

 rename .1.gz.html .html *.1.gz.html


 rename 's/\.1\.gz\.html/\.html/' *.1.gz.html

The first version is a bit easier to write the second one is more powerful and sometimes available as perl-rename. Have a look at man rename to find the correct syntax.

  • The 2nd rename worked. The first and simple one gave me an error. I have version 5.20.2 of rename installed.
    – linstar
    Jul 5, 2015 at 12:02
  • This also worked for me: rename 's/1\.gz\.//' *.1.gz.html
    – linstar
    Jul 5, 2015 at 12:12

A wildcard like that gets expanded into everything that matches it before the mv command even runs. Making matters worse is that *.html will also match your *.1.gz.html files.

This means that (for example two files named abc.1.gz.html and def.1.gz.html) your command above is essentially running:

mv abc.1.gz.html def.1.gz.html abc.1.gz.html def.1.gz.html

This will try and move abc.1.gz.html and def.1.gz.html into a directory called def.1.gz.html. Thankfully this fails as that file is not a directory.

You'll need to script something to look at each file one at a time eg:

for file in *.1.gz.html; do
  mv "$file" "`echo $file | sed 's/\.gz\.html$/.html/'`"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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