Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 08-29-2005, 12:09 PM   #1
LQ Newbie
Registered: Mar 2005
Posts: 7

Rep: Reputation: 0
Scripting question

I'm doing some work scanning a large amount of files into a computer system. I'm stuck with the software that's been dumped on me for the time being, so I'm looking for a quick way to organize and name what I've got. Here's the current situation:

The scanning software propts for a job name, which is then used as a directory name. Each page is saved as an individual tiff file, 0000001.tif to xxxxxxx.tif, depending on the number of pages. So, each document sits in its own directory. The directory name is important, since it identifies what the document is. I'm scanning in Windows, but I've moved the files to my linux box.

My questions:

Can I use a script to automatically combine all the tiffs in a given directory (using tiffcp, perhaps) and convert to pdf (tiff2pdf?).

How can I make that script, and how can I make it run recursively, so I don't have to manually enter each directory?

Is it possible, once that's done, to run another script where each of the newly created PDFs are given the same name as the directory they sit in? The way things are set up, each directory should only contain a single PDF, so there won't be repeating filenames within a directory.

And while I'm at it, the scanning software is tossing in extra files I don't want. Is there a way to delete all files with a given extension within all subdirectories? Again, there's a lot of manipulation going on, all of it pretty basic, but it's spread out in so many sub directories that doing it by hand would take forever.

Thanks in advance for any help.


ETA: Just after I posted, I figured out how to delete the files in subdirectories, so all those .dat files are gone. Ignore the last question.

Last edited by msandford; 08-29-2005 at 12:28 PM.
Old 08-29-2005, 12:19 PM   #2
LQ Guru
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Deleting files with a given extension (assumes .BAD, case insensitive, replace as needed):
find /directory -iname '*.bad' -print0 | xargs -0 rm
I will investigate your tiff issues and post any thoughts here later.
Old 09-03-2005, 02:55 PM   #3
LQ Newbie
Registered: Mar 2005
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks for the help so far. That made things much easier for me. As for the tiff stuff, I wrote a basic script, and I'm just running it on each directory. It's time consuming, but it's got to get done.

Old 09-04-2005, 04:03 AM   #4
Registered: Oct 2004
Location: Tartu, Ċrhus,Nürnberg, Europe
Distribution: Debian, Ubuntu, Puppy
Posts: 619

Rep: Reputation: 45
try something like this:

cd dir_where_your_tiff_dirs_are
for dir in $(ls); do  # do the following on all files/dirs
  if [ -d $dir ]; then  # only if it is a directory
    cd $dir
    #do something with the files here...
    # perhaps remove the files
    cd ..
    # perhaps rmdir $dir
I haven't tested it, though.

Old 09-05-2005, 11:23 AM   #5
Registered: Sep 2003
Location: Manchester UK
Posts: 264

Rep: Reputation: 30
I know I'm probably being cheeky here, but did you resolve this issue?

If you did, I'd love to take a look at the script you are using as I've just been lumbered with a similar job - for 30,000 pieces of A4 paper...

Many Thanks,


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
scripting question... Basslord1124 Linux - Networking 2 11-09-2005 06:52 AM
Scripting Question... Darklight451 Linux - Newbie 3 09-23-2004 06:03 PM
Scripting question sujte Linux - General 2 05-24-2004 05:52 PM
Scripting question aikitortoise Linux - Newbie 3 11-14-2002 06:18 PM
New to Scripting question s&j Linux - General 2 06-25-2002 09:27 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:19 PM.

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