01-16-2012, 04:10 PM
Need to find all empty files and folders in current category, show their creation date and time, and delete them.
For finding and deleting I tried using:
Same with files:
But how with their names? Tried to use:
But this gives only directories. Then i used this code:
so I think date then file was last modified would better to write.. But how?
I can find for example files that were modified certain time ago..
But how to put it all together? What script would search current dirrectory for empty files and folders, delete them and show names and date (creation/edition) of those deleted files?
Any ideas?
For finding and deleting I tried using:
Code:
find . -maxdepth 1 -type d -empty -exec rmdir {} \;
Code:
find . -maxdepth 1 -type f -empty -exec rm ;
Code:
find . -maxdepth 1 -type d -empty;
find . -maxdepth 1 -type d -empty -exec rmdir {} \;
Quote:find . -maxdepth 1 -type d -empty -exec ls -l;But it gives plenty more information.. Creation date is not saved on UNIX,
find . -maxdepth 1 -type d -empty -exec rmdir {} \;
so I think date then file was last modified would better to write.. But how?
I can find for example files that were modified certain time ago..
Code:
find . -mtime -1 -print
But how to put it all together? What script would search current dirrectory for empty files and folders, delete them and show names and date (creation/edition) of those deleted files?
Any ideas?