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.
The following did the trick.
find . -depth -name "*.zip.zip" -exec sh -c 'mv "$1" "${1%.zip.zip}.zip"' _ {} \;
Recursively renaming files using globstar and rename:
Renaming files using mmv:
;
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.