Download Genius Scan for iPhone documents with PowerShell

I love Genius Scan for iPhone. It basically lets you take pictures of anything (like receipts, printouts of actual documents etc.,) and converts it to a .pdf and stores it within the app. A .pdf document can be made up more than one image (multi-page document). You can even use existing images in your photo stream or your album to create the document (I prefer this method). What’s more? It is free!

IMG_1300

If you want to then download the scanned documents to your computer, it enables Wifi sharing

IMG_1298

So far, so good. When you navigate to the URL, it lists all the scanned documents available for download:

WebAccess

Do you notice something? If you wanted to download these documents, you have to do them one at a time. This is not a design flaw on the part of the developer. I don’t blame him for trying to sell his paid version that syncs all the files to DropBox or anywhere else on the cloud or the computer. For the cheapskates like me, this is it. No “Download All” links or anything. You have to right-click and save one file at a time.

I had 50+ files and was unwilling to right-click and save even though it was only 50+ times. I wanted a program to do it for me and it had to be a PowerShell script. Here it goes. I know it could be made a lot better but for those of you wanting to do what I did, you could just copy the list of files from the screen and make an array and loop through to download them.

PowerShell Script

$SourceList=
“2011-12-26 11-51 (2011-12-26 115117).pdf”,
“2011-12-26 11-51 (2011-12-26 115158).pdf”,
“2011-12-27 06-01 (2011-12-27 060158).pdf”,
“2012-02-09 12-54 (2012-02-09 125433).pdf”,
“2012-02-09 13-01 (2012-02-09 130126).pdf”,
“2012-04-12 09-33 (2012-04-12 093344).pdf”,
“2012-04-20 17-22 (2012-04-20 172238).pdf”,
“2012-06-04 15-37 (2012-06-04 153752).pdf”,
“2012-10-26 14-51 (2012-10-26 052136).pdf”,
“2012-11-16 05-27 (2012-11-16 052744).pdf”,
“2012-12-18 08-04 (2012-12-18 080430).pdf”,
“2012-12-19 04-24 (2012-12-19 042415).pdf”,
“2013-01-04 07-22 (2013-01-04 072229).pdf”

$webclient = New-Object System.Net.webclient
$destination = “c:\MyDocs\”

foreach ($file in $SourceList ) {
$sourceFile = http://122.122.1.7:8083/files/ + $file
$destinationFile = $destination + “/$file”

“Copying $sourceFile to $destinationFile”
$webclient.DownloadFile($sourceFile, $destinationFile)
}

“Done copying!”

I could have done something more elegant like detecting the links but the webpage source was putting that together dynamically with a JavaScript.

<script type="text/javascript" charset="utf-8">
var now = new Date();
$.getJSON("/files?"+ now.toString(),
function(data){
$.each(data, function(i,item){
encodeName = encodeURI(item.name).replace("'", "&apos;");
$("<div class='file'><img class='pdficon' src='pdf.png' width=17 height=17><a href='/files/" + encodeName + "' class='file'>" + item.name + "</a></div>").appendTo("#filelist");
});
});
</script>

The next best option would be to not have to format the strings but instead be able to just copy the file-list between the starting @” and ending “@ below for the variable $SourceList – something like this (not tested):

Alternate PowerShell Script (not tested)

$SourceList=@”
2011-12-26 11-51 (2011-12-26 115117).pdf
2011-12-26 11-51 (2011-12-26 115158).pdf
2011-12-27 06-01 (2011-12-27 060158).pdf
2012-02-09 12-54 (2012-02-09 125433).pdf
2012-02-09 13-01 (2012-02-09 130126).pdf
2012-04-12 09-33 (2012-04-12 093344).pdf
2012-04-20 17-22 (2012-04-20 172238).pdf
2012-06-04 15-37 (2012-06-04 153752).pdf
2012-10-26 14-51 (2012-10-26 052136).pdf
2012-11-16 05-27 (2012-11-16 052744).pdf
2012-12-18 08-04 (2012-12-18 080430).pdf
2012-12-19 04-24 (2012-12-19 042415).pdf
2013-01-04 07-22 (2013-01-04 072229).pdf
“@

$webclient = New-Object System.Net.webclient
$destination = “F:\MyDocs”
$files = $SourceList.Split(“.pdf”)
$files

foreach ($file in $files)
{
$sourceFile = http://122.122.1.7:8083/files/ + $file + “.pdf”
$destinationFile = $destination + “/$file” + “.pdf”

“Copying $sourceFile to $destinationFile”
$webclient.DownloadFile($sourceFile, $destinationFile)
}

“Done copying! Copied $($files.count) files”

Next time, I am still going to refuse to right-click. I will instead use this script.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s