The other day my co-worker showed me how to send our tapes offsite. Apparently you need to format the list of tapes in a certain way. So you can input the info to the Iron Mountain site for pickup. He was going though several steps to change the format in Excel. I told myself there has to be a better way, so wrote a script shown below.
First you need to put all the tapes in a list. I put the tape list in the file called list shown in the example below. Then I run the script, I created (tape-input.sh). I take the output and paste it into the web portal.
list
U00010L5
U00011L5
U00012L5
U00013L5
U00014L5
U00015L5
U00016L5
U00017L5
U00018L5
U00019L5
U00020L5
U00021L5
U00022L5
U00023L5
U00024L5
U00025L5
U00026L5
U00027L5
U00028L5
U00029L5
U00030L5 CAT
U00011L5
U00012L5
U00013L5
U00014L5
U00015L5
U00016L5
U00017L5
U00018L5
U00019L5
U00020L5
U00021L5
U00022L5
U00023L5
U00024L5
U00025L5
U00026L5
U00027L5
U00028L5
U00029L5
U00030L5 CAT
tape-input.sh
#!/bin/bash
# Created to format the tapes numbers to add to the web portal
echo -e "Packaged by man, $(date|awk '{print $2" "$3" "$6}')"
cat list |sed ':a;N;$!ba;s/\n/, /g'| perl -pe 's{,}{++$n % 3 ? $& :"\n"}ge'
# Created to format the tapes numbers to add to the web portal
echo -e "Packaged by man, $(date|awk '{print $2" "$3" "$6}')"
cat list |sed ':a;N;$!ba;s/\n/, /g'| perl -pe 's{,}{++$n % 3 ? $& :"\n"}ge'
man@earth> ./tape-input.sh
Packaged by man, Dec 13 2018
U00010L5, U00011L5, U00012L5
U00013L5, U00014L5, U00015L5
U00016L5, U00017L5, U00018L5
U00019L5, U00020L5, U00021L5
U00022L5, U00023L5, U00024L5
U00025L5, U00026L5, U00027L5
U00028L5, U00029L5, U00030L5 CAT
I take the output and paste it into the Iron Mountain web portal for pickup.Packaged by man, Dec 13 2018
U00010L5, U00011L5, U00012L5
U00013L5, U00014L5, U00015L5
U00016L5, U00017L5, U00018L5
U00019L5, U00020L5, U00021L5
U00022L5, U00023L5, U00024L5
U00025L5, U00026L5, U00027L5
U00028L5, U00029L5, U00030L5 CAT
I hope this helps someone out. If you have any questions please ask below.
No comments:
Post a Comment