Разархивируйте несколько ziped и автоматически переименуйте файлы с одинаковым именем, если это необходимо

276
FXux

У меня есть несколько файлов Ziped в папке, и я хотел бы разархивировать все, но автоматически переименовывать папки или файлы с тем же именем, например:

В ZIP_folder_1.zipи у ZIP_folder_2.zipменя есть одна папка с именем my_name, если я распаковать все с вышеуказанной команды, командная строка будет спросить, если я хочу переименовать его, поэтому, если у меня есть 3k папки с таким же именем, я сойду с ума.

Я пытаюсь использовать:

find . -type f -name "*.zip" -exec unzip {} -d {}.contents/; 

Но я вижу

find: missing argument to `-exec' 

Другой момент: я могу передать папку назначения?

Спасибо!!!

Благодарю.

0

1 ответ на вопрос

0
infixed

The argument to -exec is typically the stuff between the -exec and the \;

I would first try putting a space between the {}.contents and the \; but I didn't test it to see what might be going on

for your other point, it's probably easier to alter the starting point for find than meddle with the -exec clause. I suggest something like below, recalling that $OLDPWD is the old working directory from prior to the last cd (at least in bash it is, in tsch it is $owd)

cd targetdirectory; find $OLDPWD -type f -name "*.zip" -exec unzip {} -d {}.contents /;

You could embellish it by adding a ; cd $OLDPWD at the end to return you to your starting point if you wanted

Похожие вопросы