Forums

How to download a directory?

Hey,

Is it possible to download a directory?

When I use the below command, it shows an I/O error 'can't create a zip file'

Command: zip -r fname my_folder_name

Any suggestions?

What is the working directory when you run the command?

It’s my home directory

Could you give the exact command that you're using? I'm wondering if while trying to make it a more generic command in order to post it here, you might have removed something that is important.

BTW when you say your home directory, you mean /home/penki37, right?

Yes, correct. Command: zip -r data penki37/

I want to zip the entire penki37 directory

You cannot put a zip file into the directory that you're trying to zip. You'll need to put the zip file in /tmp if you want to zip your entire home directory.

I’m actually executing the command outside the directory.

I’m executing it in home directory. Could you provide the command or instructions to zip penki37 directory?

Thanks!

Ah, that would explain the problem -- /home/ is a directory that would contain multiple users' home directories if the other users on the system were visible, so you don't have write permissions.

If you want to zip up your whole home directory, then the best place to put the zip file would be in /tmp, where you do have write permission. The command would be:

zip -r /tmp/backup.zip /home/penki37

Then to download it, you can go to your /tmp/ directory (that link will only work for you, not for other people browsing these forums) and click the download icon.

One alternative to zipping for anyone still interested is to use sftp. you can connect to your python anywhere directory using sftp by entering

sftp your_username@ssh.pythonanywhere.com

and providing your password when prompted. then navigate to the parent directory of the directory you wish to download and enter

get -r your_directory

Thanks, @Thermodev, that would only work on paid accounts, though.