0

My question is almost the same as those, however, its solution doesn't work my for my case. I'd like to remove duplicated extension (in my case .zip.zip) and have only one (i.e. .zip). I tried:

rename 's/.zip/.zip$/.zip/' *.zip.zip

and

find . -depth -name "*.zip.zip" -exec rename 's/\.zip\.zip$/.zip/' {} +

But in both case no file was renamed.

menteith
  • 271

2 Answers2

0

The following did the trick.

find . -depth -name "*.zip.zip" -exec sh -c 'mv "$1" "${1%.zip.zip}.zip"' _ {} \;

menteith
  • 271
0

Recursively renaming files using globstar and rename:

$ shopt -s globstar; rename 's/\.zip$//' **/*.zip.zip

Renaming files using mmv:

$ mmv ';*.zip.zip' '#1#2.zip'
       12            ^ ^
  • ; matches files at any depth in the directory tree.
  • * Matches any char zero or more times.
  • # References to the nth wildcard char in the from pattern.