Raw extraction problems with dcraw

Hi,

I'm really a newbie in linux system! Please bear with me.
The problem is every time I run the shell script, it deletes all the files in the target directory and left one D source code type file with name: *.ppm.d.

Can anyone help me with this??
Thanks in advance!

what I'm trying to do is:

  1. use dcraw to extract all *.raw in one directory. outputs are *.ppm. (The shell script let you type in the directory to work in)

  2. remove all *.raw

  3. doing a bit image processing with double.c(outputs are *.d)

  4. remove all *.ppm files

  5. remove *.d extension of all files

Here is the code:

#!/bin/sh
cd /home/pi/dcraw/
echo "Enter target directory: "
read filename


for file in "$filename/*.raw";
do
./dcraw "$file";
done


cd $filename
rm *.raw


for file in "$filename/*.ppm";
do
double $file > ${file}.d;
done


rm *.ppm


for file in "$filename/*.d";
do
mv -- "$file" "${file%%.d}";
done

Wildcards inside quotes do not expand. How about this:

#!/bin/sh
cd /home/pi/dcraw/
echo "Enter target directory: "
read filename

for RAW in "$filename"/*.raw
do
        PPM="${RAW/.raw/.ppm}"
        PPMD="${RAW/.raw/.ppm.d}"

        ./dcraw "$RAW"
        double "$PPM" > "$PPMD"
        rm "$RAW" "$PPM"
        mv "$PPMD" "$PPM"
done

I can't find any information on this 'double' utility but it may be possible to do this with no temp files at all if you can tell me what it is.

1 Like

It might work something like ./dcraw -c filename.raw | double /dev/stdin > filename.ppm

the double program is in C. Its just an image processing tool to double the rows of an image, so as to strech it vertically.
Thanks for your help!!!!!!

I ll try your method right away

------ Post updated at 08:43 PM ------

it worked partially. Even though with some warnings.

Seems the double function did not apply.

PPM: not found
PPPMD: not found

cannot create: directory nonexistent
rm: cannot remove no such file or directorry
mv: cannnot stat no such file or directo

Thx!!!

------ Post updated at 08:45 PM ------

I have to ask what does ' |' mean and what is /dev/stdin behind double?

Did you copy Corona688's script char by char, keystroke by keystroke? The $ - signs are important for variable expansion.

The pipe symbol | connects (pipes) one command's standard output (stdout) to another's standard input (stdin). With it, you can construct powerful, versatile compound commands from single simple tools / commands.
/dev/stdin is a (formal) symbolic link to a process' stdin, used in case a command explicitely needs a file name as an argument.