I am following this question to extract a zip. Is there a way to automatically add a number after the file extracted when there is an existing file with the same name?
For example, I have example.zip
with a file called contents.csv
. My directory is this:
contents.csv example.zip
Currently, when I unzip the folder I get prompted:
$ unzip example.zip
Archive: example.zip
replace contents.csv? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
Instead, I just want to run unzip example.zip
then have a number (-1
) automatically appended to the file name in the case of a clash like this:
contents-1.csv contents.csv example.zip
Running unzip example.zip
again would give this:
contents-2.csv contents-1.csv contents.csv example.zip
Some GUI software already does this, but I want to do it from a script.