Gmail Pony: Context sensitive attachment downloads?
September 7, 2018 12:09 PM   Subscribe

Can I set Gmail to download attachments of certain file types to different folders?

This is for Gmail in Chrome on Win10.
I get daily emails with file attachments of various types, and I'd really like it if, when I click Download, it put all the .wav files in one folder, and all the .jpg in a different folder. I've looked at Chrome Extensions and there are a couple of options that do this but they also automatically download all matching attachments, which I don't really need (but am willing to experiment with).

If the answer is that I need to make Chrome ask me where to save file downloads every time, I guess that's what I'll do, but maybe the hive mind knows a trick or extension or hack that'll work?

What's happening is I get voicemails (.wav), faxes (.pdf), and scans (.jpg) sent regularly. Most of the time I don't need to interact with them, and so I let Gmail store them, and only download as needed. I'm spending a lot of time every month cleaning up my downloads folder and sorting things into folders and it'd be nice if they just sorted themselves at the point of download.
The truth is that none of this would be a problem if I could find a working player/plugin/app that would let me play those .wavs in Chrome, but I've tried Music Player for Google Drive, Audio Converter, TwistedWave, and they all error out.
posted by ApathyGirl to Computers & Internet (4 answers total) 1 user marked this as a favorite
 
It would be exceedingly easy to write a script that you could leave in your Downloads folder and just double-click on to move all files of any number of predefined types from Downloads into predefined homes all at once. Would that do? Happy to write it for you if so.
posted by flabdablet at 1:22 PM on September 7, 2018


I haven't had time to try this all out, but there's a possible path and it seems like it could run automatically:

1) GMail lets you filter and label incoming email by attachment type if you set up a filter and click "Has Attachment" and then under "Has the Words" you enter "filename:(wav)". This only looks the name and not the actual data, but that doesn't seem to be a problem here.

2) You want the filter to label the email with a unique label, like "Voicemails". Repeat for all other file types you want to grab.

3) Now, this script seems to be able to grab attachments from GMail and move them a folder on Google Drive. It uses a typical filter setup to determine what emails are captured, and it can look at labels. If your incoming email has been labelled by attachment in step 1, this script should be able to get the files downloaded into unique Google Drive folders.

4) Finally, use Google Drive or File Stream to sync attachments from Drive to your PC.

Whew. The only catch might be that the Labnol script only does one filter at a time unless you pay for the full version. It also seems to run every 15 minutes and not in real time as mail comes in.
posted by JoeZydeco at 1:56 PM on September 7, 2018


Went ahead and wrote that manual tidy-up script anyway, since it really is very small. If you want to play with it:

Open a new Notepad window and paste in the script below.

Edit the lines that look like set .jpg=C:\Users\ApathyGirl\Pictures\Downloaded to define the relationships you want between file types and destination folders. You can add as many of these lines as you like; just make sure that there's a space after set, no spaces around the =, and that the file type before each = starts with a dot. The script will make any destination folders that don't already exist.

Save the result into your Downloads folder as ~tidy.cmd (the ~ at the start of the name will make Windows Explorer treat it as coming before "a" in the alphabet so it will be easy to find inside a crowded Downloads folder). When you're doing the Save As, change the "Save as type" from "Text Documents (*.txt)" to "All Files", otherwise Notepad will make tidy.cmd.txt which won't work.

Opening your Downloads folder in Windows Explorer and double-clicking on ~tidy should then automatically move all the files of the types you made set lines for into the folders you named in those lines.

You can alter the filetypes the script will process and/or the folders it will file them into by right-clicking it and choosing Edit; this will open it up again in Notepad, and if you use Save rather than Save As when you've finished editing it, you won't need to do the "Save as type" dance again.
@echo off
setlocal enabledelayedexpansion
for /f "tokens=1 delims==" %%V in ('set .') do set %%V=

set .jpg=C:\Users\ApathyGirl\Documents\Attachments\Scans
set .pdf=C:\Users\ApathyGirl\Documents\Attachments\Faxes
set .wav=C:\Users\ApathyGirl\Documents\Attachments\Voicemails

for %%F in (*.*) do if defined %%~xF (
	mkdir "!%%~xF!\" 2>nul
	move /-y "%%~F" "!%%~xF!\"
)

posted by flabdablet at 2:33 PM on September 7, 2018 [8 favorites]


Here's another version of ~tidy.cmd that's more informative while running, makes some attempt to handle errors gracefully, automatically opens Explorer windows for any folders it actually moves things into, and has rules that are less fiddly to edit. Instead of a bunch of set commands near the start that are finicky about syntax, this one just has lines at the end (as many as you need) consisting of a filename extension without a leading dot, followed by one or more spaces or tabs, followed by the pathname for the folder to move files of that type into.
@echo off
for /f "usebackq tokens=1* skip=12" %%E in ("%~f0") do if exist *.%%E (
	mkdir "%%F\" 2>nul
	if exist "%%F\" (
		explorer "%%F\"
		echo Moving %%E files into %%F:
		move /-y *.%%E "%%F\"
	) else echo Can't find or make folder %%F.
	echo.
)
set /p input=Press Enter: 
goto :eof

jpg	C:\Users\ApathyGirl\Documents\Attachments\Scans
pdf	C:\Users\ApathyGirl\Documents\Attachments\Faxes
wav	C:\Users\ApathyGirl\Documents\Attachments\Voicemails

posted by flabdablet at 6:04 AM on September 8, 2018 [1 favorite]


« Older How to enjoy myself around Asia?   |   Dedicated Writing Device Suggestions Newer »
This thread is closed to new comments.