Create CD catalogue using Shell Script
I am making a record of all the files on a CD. All the files on the CD should be listed in a text file using this format:
CD Volume Name;Path and name of file;Modification Time;Size in bytes;Comment;<Newline> The result should look like this: Adios;/adk/Makefile;24/02/04 13:03:36;20865;Adios files on CDROM; .... My head is spinning and I am not sure where to start. I have used the 'find' utility to print the ;Path and name of file; to the text file. The problem is appending the ;Modification Time; Size in bytes; and so on. To make it even more complicated; The user should be allowed to add a comment to each record. I greatly appreciate any help or comments! - Helene |
Try using
#!/bin/bash # Read cd name: cd_name=`isoinfo -d -i /dev/cdrom | grep 'Volume id: ' | sed 's/Volume id: //'` # Loop through each file on disc: for cd_path in `find /mnt/cdrom` # Get modification in "dd/mm/yy hh:mm:ss" format do cd_mod_time=`stat -c %y $cd_path | cut -c 1-19 | sed 's/[0-9]\{2\}\([0-9]\{2\}\)-\([0-9]\{2\}\)-\([0-9]\{2\}\)/\3\/\2\/\1/'` # Get file size in bytes: cd_size=`stat -c %s $cd_path` # Get comment: echo -n "Enter comment for file $cd_path: " read cd_comment # Output record: echo "$cd_name;$cd_path;$cd_mod_time;$cd_size;$cd_comment;" done and work on that. I have guessed about the functionality required in places however I hope it helps. |
You made my day , nhs. Everything seems to work so far. Thank you very much!
|
All times are GMT -5. The time now is 03:01 AM. |