LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-09-2004, 10:51 AM   #1
Helene
LQ Newbie
 
Registered: Apr 2004
Posts: 19

Rep: Reputation: 0
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
 
Old 04-09-2004, 01:32 PM   #2
nhs
Member
 
Registered: Aug 2003
Location: Edinburgh, Scotland
Distribution: Gentoo
Posts: 246

Rep: Reputation: 30
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.
 
Old 04-09-2004, 09:42 PM   #3
Helene
LQ Newbie
 
Registered: Apr 2004
Posts: 19

Original Poster
Rep: Reputation: 0
You made my day , nhs. Everything seems to work so far. Thank you very much!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script inside shell script treotan Linux - General 4 02-19-2009 06:34 AM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
How to create a shell script that reads something from stdin? ricky_ds Programming 2 05-17-2005 05:06 AM
[SHELL SCRIPT] Write at the right of the shell window Creak Linux - General 2 04-02-2004 03:00 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration