Re: wrote directory full of pictures in a file urgggg!
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Thu, 14 Feb 2008 14:43:10 -0800
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"
.
- Follow-Ups:
- Re: wrote directory full of pictures in a file urgggg!
- From: hoodcanaljim
- Re: wrote directory full of pictures in a file urgggg!
- References:
- wrote directory full of pictures in a file urgggg!
- From: hoodcanaljim
- Re: wrote directory full of pictures in a file urgggg!
- From: Bill Marcum
- Re: wrote directory full of pictures in a file urgggg!
- From: hoodcanaljim
- wrote directory full of pictures in a file urgggg!
- Prev by Date: Re: wrote directory full of pictures in a file urgggg!
- Next by Date: Re: wrote directory full of pictures in a file urgggg!
- Previous by thread: Re: wrote directory full of pictures in a file urgggg!
- Next by thread: Re: wrote directory full of pictures in a file urgggg!
- Index(es):
Relevant Pages
|