Created
January 19, 2018 08:37
-
-
Save azechi/a8b70d05a0f01dec289a18421f6db92d to your computer and use it in GitHub Desktop.
WindowsのSendToでWebページのショトートカットファイルを"[title url]"の文字にしてクリップボードに保存する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @fsi --exec %HOME%\bin\Clip_URLShortcut.fsx %* | clip | |
| @pause |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #r "Microsoft.VisualBasic.dll" | |
| open System | |
| open System.IO | |
| open System.Runtime.InteropServices | |
| open System.Text | |
| open Microsoft.VisualBasic.FileIO | |
| [<DllImport("kernel32.dll", CharSet = CharSet.Unicode)>] | |
| extern int GetPrivateProfileString(string _section, string _key, string _def, StringBuilder _retVal, int _size, string _filePath); | |
| let getUrl = | |
| let buff = StringBuilder 255 | |
| fun path -> | |
| buff.Clear() |> ignore | |
| GetPrivateProfileString ("InternetShortcut", "URL", "", buff, 255, path) |> ignore | |
| buff.ToString() | |
| >> (fun s -> if String.IsNullOrWhiteSpace s then None else Some s) | |
| Array.skip 1 fsi.CommandLineArgs | |
| |> Array.filter (Path.GetExtension >> (=) ".url") | |
| |> Array.map (fun path -> path, getUrl path) | |
| |> Array.filter (snd >> Option.isSome) | |
| |> Array.iter | |
| (fun (path, url) -> | |
| let title = Path.GetFileNameWithoutExtension path | |
| printfn "[%s %s]" title url.Value | |
| FileSystem.DeleteFile (path, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin) | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ファイルは複数でも可
拡張子が".url"でiniファイル形式
"InternetShortcut"セクションの"URL"キーの値を取得する
URLが取得できたファイルはごみ箱に入れる