lundi 4 avril 2016

bash scripts: 1. Encrypt/Decrypt a folder; 2. Recursively copy files from many directories to one with random num at beginning of the filenames

I've been searching the Internet for quite some time, on and off for probably months, trying to figure out how to do this, cobble together multiple answers to somewhat-relevant questions, etc. I just can't figure out how to do it. I hate to make such a complicated request but I really don't know what to do. Sometimes I put things together and get errors I can't understand, like that a folder or directory that exists doesn't exist. Combinations of mv, cp, ../, openssl, etc. combine in totally nonfunctional ways in my hands.

Here's what I want to do:

I have a directory structure like this:

/home/ados/
  clickityclack/
    EncryptingScript
    EncryptMe/
      PullAndDumpScript
      DumpHere/
      00000001/
        file1
        file2
        file3
      00000002/
        file4
        file5
      00000003/
        file6
        file7
        filepotato
        file9

I would like a bash script, EncryptingScript, that will encrypt EncryptMe/ to DecryptMe in the same directory the script and EncryptMe are in. It doesn't need to be especially secure, but should have a password. I want to be able to choose, from the same script, whether to encrypt or decrypt (this is pretty straightforward, I think; I got that bit going actually). Also, the script has to automatically use filepaths relative to the folder the script is in, rather than /, for portability reasons.

Second, another script, again relative to current location (clickityclack/EncryptMe/ in this case), would delete all files in DumpHere/, then copy all the files in the numbered folders (which go beyond 00000003 as high as I need) into DumpHere/, adding a random number to the beginning of the filename so they'll be in a different order each time I run the script.

Is there a way to do this? Thanks so much for any help you can provide. By all means, ask any clarifying questions.




Aucun commentaire:

Enregistrer un commentaire