Results 1 to 3 of 3
Hi All,
I have zero knowledge in UNIX, so i desperately need the help from you guys.
I need a script which can encrypt all the text files in one ...
- 08-28-2011 #1Just Joined!
- Join Date
- Aug 2011
- Posts
- 1
How to write a script for text file encryption?
Hi All,
I have zero knowledge in UNIX, so i desperately need the help from you guys.
I need a script which can encrypt all the text files in one shot in a source directory.
After all the text files are encrypted, they will be put into a separate folder.
Command involve:
gpg with -a, --armor
eg.
Before encyption:
/main/project/sorce/file1.txt
/main/project/sorce/file2.txt
/main/project/sorce/file3.txt
Before encyption:
/main/project/target/file1.txt.gpg
/main/project/target/file2.txt.gpg
/main/project/target/file3.txt.gpg
- 08-29-2011 #2Linux Guru
- Join Date
- May 2011
- Posts
- 1,842
I don't think you can do it in "one shot", but a simple bash loop should do it for you.
Read up on loops in bash, and read the gpg manpage and you should have your script within minutes.
- 08-29-2011 #3Just Joined!
- Join Date
- Aug 2011
- Location
- London, UK
- Posts
- 19
I can't post a link but here's the syntax you need for gpg:
echo password | gpg --batch -q --passphrase-fd 0 --cipher-algo AES256 -c /tmp/file.tgz
Create a basic bash script that uses the first parameter as the path to the plaintext file and create a loop as suggested above. You can then do things like: ./batchencrypt *.doc


Reply With Quote