I have multiple password protected files in a directory eg:
file123.dat
file456.dat
file789.dat etc
I will be writing a script in linux to extract them with their passwords. each file has its own filename as password how can i extract the names of the files and put them in the script? NOTE:the password are certain alphabets from the filename and not the entire filename I am using 7zip to extract the file. The script i am using now is :
#!/bin/bash
FILES=`ls *.zip | xargs -r`
for FILE in $FILES; do
PASSWD=`echo $FILE | awk '{print substr($0,1,2)}'`
`echo abc``echo $FILE | awk '{print substr($0,5,2)}'`
7za X -p $PASSWD $Z_FILE //using 7zip to unzip
if [ $? = 0 ]; then # successful unzip
break
fi
done
done