Forrest logo
back to the for tool

for:ai:df84c

how do I archive every file in a directory into their own rar archives?
$ for file in *; do rar a "$file.rar" "$file"; done
try on your machine

This command uses a for loop to iterate through every file in the current directory and creates a rar archive for each file, with the same name as the original file but with the .rar extension.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.

Questions that are answered by this command:

  • how do I archive every file in a directory into their own rar archives?
back to the for tool