Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using the following script to auto download files from my remote seedbox using lftp:

set ftp:list-options -a
set ftp:ssl-allow no
set mirror:use-pget-n 5
set cmd:fail-exit true
open ftp.myseedbox.com
mirror -c -P5 --Remove-source-files --log=synctorrents.log /completed /media/ExternalHd/
quit

Now, this removes files after successful transfer but leaves empty folders. Is there any method/script code to automatically remove empty folders ?

share|improve this question

1 Answer

up vote 1 down vote accepted

Linux has an inbuilt tool for this, rmdir:

$ man rmdir
NAME
       rmdir - remove empty directories

SYNOPSIS
       rmdir [OPTION]... DIRECTORY...

DESCRIPTION
       Remove the DIRECTORY(ies), if they are empty.

You can safely run a command like rmdir * since it will ONLY remove empty directories.

share|improve this answer
I need to do this as an automated task using scripting after lftp completes its job on remote computer. Any ideas on how to do this using lftp ? – DeepeshAgarwal Nov 21 '12 at 14:13
@DeepeshAgarwal, I don't have any experience with lftp but can't you just add rmdir /completed/* after mirror and before quit? – terdon Nov 21 '12 at 14:25
1  
@DeepeshAgarwal, I just checked and [linux.about.com/od/commands/l/blcmdl1_lftp.htm](lftp supports the rmdir command). So, you should just be able to add rmdir /remote/path to your script between mirror and quit. – terdon Nov 22 '12 at 18:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.