Created for COMP 4262-001 at the University of Memphis, Fall 2014
Instructor: Dr. Zhou Lu
Project by Dr. Zhuo Lu
Code by Keenan Diggs, 2014
Documentation by Keenan Diggs, 2014
smartdel is a linux file-manipulation utility and extension of the mv command. The code is contained in a single shell script. It is powerful and robust, capable of restoring all files in a recycle bin directory to the locations they were initially deleted from, while accounting for name collisions.
smartdel initializes a 'smartdel_recycle' recycle bin directory as a child of the user's home directory and a '.table.txt' file inside the bin.
Upon file deletion, files are moved to the recycle bin and the filename and filepath 2-tuples are stored in the .table.txt file, where they can later be recovered and used. In the bin, files are stored in the format filename_version, where version is an integer.
Upon file recovery, the user specifies whether the selected files are moved to the present working directory or to the directory from which they were originally deleted from.
In addition, smartdel supports wilcard characters '*' and '?', but for restoring, parameters passed to smartdel with them must be contained in single or double quotes.
Finally, smartdel supports the deletion and restoration of identical filenames. If files with identical names are deleted from separate directories, smartdel can restore them simultaneously. However, if the same filename is deleted from the same directory 2 or more times, the user will decide which version of the file to restore. In this event, smartdel will provide a numbered list of file descriptions, from which the uses chooses one. The file descriptions contain the time last edited, filename_version as stored in the recycle bin, and directory from which the file was originally deleted from.
Options:-d (delete)
-r (restore)
-o (smart restore)
-s (smart restore simultaneous files)
-c (permanently delete all files in recycle bin)
(option omitted, behavior is identical to -d)
The delete option allows the user to send files, or file patterns if wildcards are used, from the specified directory to the recycle bin. The file is moved with a new name of the form oldfilename_version. If no option is specified and a paramenter is immediately input, smartdel behaves as though -d has been specified. 'smartdel -d filename' is equivalent to 'smartdel filename'.
The restore option allows the user to restore files from the smartdel_recycle bin to the present working directory. Wildcards are supported, but such patterns must be passed in with single or double quotes. If multiple files of the same filename have been deleted and are residing in the recycle bin, the user will have to specify which file to restore by inputting an integer from the keyboard and pressing Enter.
The restore option allows the user to restore files from the smartdel_recycle bin to the present working directory. Wildcards are supported, but such patterns must be passed in with single or double quotes. If multiple files of the same filename have been deleted and are residing in the recycle bin, the user will have to specify which file to restore by inputting an integer from the keyboard and pressing Enter based on a numbered list of file descriptions.
The smart restore (simultaneous) option allows the user to restore files from the smartdel_recycle bin to the directory in which they were smartdeleted from. If multiple files of the same name with different source directories are in the recycle bin, smartdel will restore them all simultaneously. Wildcard characters are supported, but such patterns must be passed in with single or double quotes.
The clear bin option allows the user to permanently delete all files in the recycle bin and reset the table. It is invoked simply as 'smartdel -c'
smartdel is of the form: smartdel [option] [parameters]smartdel -d filename, or equivalently: smartdel filename
smartdel -d /home/path/to/filename
smartdel -d ../filename
smartdel -d ~/Documents/path/to/filename
smartdel -d subdir/grandchild/filename
smartdel -d filename1 filename2 filename3
smartdel -r filename1
smartdel -r filename1 filename2 filename3 path/to/filename4
smartdel -r 'filena*'
smartdel -r 'fil?name?'
smartdel -o filename1
smartdel -o 'fi*name'
smartdel -o '?ilename2'
smartdel -o filename1 filename2 filename3
smartdel -s filename
smartdel -s '*'
smartdel -c