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:
use dcraw to extract all *.raw in one directory. outputs are *.ppm. (The shell script let you type in the directory to work in)
remove all *.raw
doing a bit image processing with double.c(outputs are *.d)
remove all *.ppm files
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
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.