Say that you have a file ‘stuff.tar.bz2’ and a folder ‘stuff’ and you want to delete the folder stuff before extracting the archive.
In python you could do:
Code:
path = path_to_archive
path = path[:path.find(‘.’)]
delete_folder(path)
Well the fun thing is, if your archive is located in ~/.local/share or some other dot directory, the erased path is your home folder!
This is a friendly reminder to:
1) Do a dry run before running code that deletes stuff
2) Activate the Ctrl+Alt+Backspace to quickly kill your session if needed
3) Setup Déjà Dup to backup your stuff daily or weekly