Hi, I have a directory of files with filenames all in the format of xxx_yyy_zzz.pdf
Where xxx and yyy changes each filename but zzz stays the same. For example: File 1: Gold_Car_Vehicle.pdf; File n: Red_Truck_Vehicle.pdf.
I need to cycle through each file and output a Text File with 2 columns. The two columns are xxx and the complete name of the pdf.
So, in the case of the two Files above, my text file would read:
Column 1 Column 2
Gold Gold_Car_Vehicle.pdf
Red Red_Truck_Vehicle.pdf
So far I have the script:
#!/bin/sh
set -e
for f in *.pdf
do
d=${f%_*.*}
for drt in $(IFS=_;echo $d)
do
d=${f%_*.*}
if [ ! -d "$drt" ]; then
echo "$drt"
echo "$f"
fi
done
done
What am I missing?