Re: wrote directory full of pictures in a file urgggg!



hoodcanaljim <hoodcanaljim@xxxxxxx> writes:
On Feb 10, 4:55 pm, Bill Marcum <marcumb...@xxxxxxxxxxxxx> wrote:
On 2008-02-11, hoodcanaljim <hoodcanal...@xxxxxxx> wrote:
Yes I screwed up again. A script that had functioned fine for
several times didn't once. I ended up with a directory full of
picture files (dscf0004.jpg) written into a single file.
Is there a way to separate out the individual files from this single
huge file??

Any help apprecitated.
Jim

If your script did something like
for file in *; do mv $file $dest; done
where $dest is a file and not a directory, all you have is the last file.
If you think the one file actually contains more than one picture, can
you post the script?

Here's the script

#! /bin/ksh

adir="../em.tj.ftbl.9oct05"

if [ ! -d $adir ]
then
mkdir $adir
fi

ls pho* | while read line
do
echo $line


if [ "$1" = "Y" ]
then
mv $line $adir
fi

if [ "$line" = "photo00021.jpg" ]
then
exit
fi

done
[...]

Apart from the logic of getting the file and directory names and
looping over the sequence of file names, the only operation your
script actually performs is a "mv" command. The "mv" command either
renames a file, or moves one or more files into a target directory;
there's no way (as far as I know) that it can concatenate two or more
files into a single larger file. You mentioend elsewhere in this
thread that the final file is very large; perhaps you just happened to
have one very large image file.

An image file with other stuff concatentated onto the end of it is
likely to act like a single image file (a viewing program will
probably just ignore any extra data), so it may be hard to tell.

A few suggestions:

You can use "mkdir -p" to create a directory if it doesn't already exist.

When moving a file into a directory, I always append "/." to the
directory name. This:
mv file dir
will rename "file" to "dir" unless "dir" exists and is a directory;
this:
mv file dir/.
will move file into the directory dir; if dir doesn't exist or isn't a
directory, it will print an error message. (Just "dir/" doesn't
necessarily suffice; on Solaris, an ordinary file "foo" can be
referred to as "foo/"; it's a stupid feature, but we're stuck with it.
Even if you're not currently using Solaris, cultivate the habit
anyway.

It seems to me that your script could probably be replaced with a
single command line:

mv pho*.jpg ../em.tj.ftbl.9oct05/.

assuming that the expansion of pho*.jpg isn't too long.

When I incorporate dates into file or directory names, I always use
YYYM-MM-DD format: "em.tj.ftbl.2005-10-09". One advantage is that it
sorts nicely; another its that it's the international standard date
format (ISO 8601).

--
Keith Thompson (The_Other_Keith) <kst-u@xxxxxxx>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.



Relevant Pages

  • Re: Backing up system
    ... space since the null filled sectors compress to almost nothing. ... That script does it, ... cleandrive5 and cleandrive6 ... Produced a 12GB compressed image file. ...
    (Fedora)
  • Re: wrote directory full of pictures in a file urgggg!
    ... picture files written into a single file. ... If your script did something like ... The second and subsequent commands each REPLACE the file that was moved ...
    (comp.unix.questions)
  • teaching myself perl - stumped on this one!
    ... She fills in a form with the recipe details and selects a image file ... the script deletes the old file properly. ... #get image from temporary image directory ... print PAGEFILE qq; ...
    (comp.lang.perl.misc)
  • Re: teaching myself perl - stumped on this one!
    ... She fills in a form with the recipe details and selects a image file ... the script deletes the old file properly. ... > #get image from temporary image directory ...
    (comp.lang.perl.misc)
  • Re: Looking for script setting a pixel marker in an image
    ... I will master up all my humble Perl knowledge and give that a try! ... image file at position x|y (whereas xmax and ymax are the maximum ... width and height of that image in pixels). ... filename.ext and the path can be define hardcoded in the script. ...
    (comp.lang.perl.misc)