Link to home
Start Free TrialLog in
Avatar of alanaldis
alanaldis

asked on

Custom Command creating multiple tar's or zip's

I am trying to find a custom command for WinSCP for creating multiple tar's or zip's.

On my server I have 100's of folders that contain images and files, what I would like to do is make a seperate tar or zip for each folder for easy downloading.

I can do this for each folder but this takes a long time doing each one seperately.

What I need is a command to take the folder name of each folder and make a tar or zip of that folder. So if I say select 50 folders it will make an individual zip or tar.

I can at the moment only make one archive of all the folders and can not find a way of making seperate archives for each folder.

The command for 1 archive is ( tar -cz  -f "!?&Archive Name:?archive.tgz!" !&)

Many thanks.
Avatar of omarfarid
omarfarid
Flag of United Arab Emirates image

you can run a remote loop like

for folder in /path/to/folder1 /path/to/forder2
do
   tar -czf /path/to/backup/$folder.tar.Z $folder
done
Avatar of alanaldis
alanaldis

ASKER

Sorry to say that does not work. I get an error (image attatched)

I need the tar's or zips to be created in same the location of the folders.

If I used this unrar command it creates and extracts to the current location (unrar x "!" "!?&Extract to directory:?.!")

Thanks.
error.jpg
note that you need to put the actual folders paths, what I gave was an example
Ok, Thanks.

But what I am trying to do is find a way so I don't need to do anything like that.

The command needs to be able to do it automatically if that is possible.

Very simular to the unrar command but in the opposite way.
ASKER CERTIFIED SOLUTION
Avatar of alanaldis
alanaldis

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial