Hugo|日時をファイル名やスラッグとした記事ファイルの生成|バッチファイル

生成するファイル名、スラッグ名が違うだけです。 下記の4件は基本的には同じファイルです。

Gakusaninfo

c:
chcp 65001
cd C:\Users\kin213\Desktop\youtubehenkan
@echo off

echo %date%
echo %time%

set yyyy=%date:~0,4%
set mm=%date:~5,2%
set dd=%date:~8,2%

set time2=%time: =0%

set hh=%time2:~0,2%
set mn=%time2:~3,2%
set ss=%time2:~6,2%

set filename=%yyyy%-%mm%%dd%-%hh%%mn%%ss%

@echo off
set TIME2=%TIME: =0%

echo ■001▲date = "%DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2%T%TIME2:~0,2%:%TIME2:~3,2%:%TIME2:~6,2%+09:00"■002▲gsinf-%filename%■03▲タイトル■04▲見出し■05▲動画ID■06▲ >> gsinf-%filename%.md

Monologue

c:
chcp 65001
cd C:\Users\kin213\Desktop\youtubehenkan
@echo off

echo %date%
echo %time%

set yyyy=%date:~0,4%
set mm=%date:~5,2%
set dd=%date:~8,2%

set time2=%time: =0%

set hh=%time2:~0,2%
set mn=%time2:~3,2%
set ss=%time2:~6,2%

set filename=%yyyy%-%mm%%dd%-%hh%%mn%%ss%

@echo off
set TIME2=%TIME: =0%

echo ■001▲date = "%DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2%T%TIME2:~0,2%:%TIME2:~3,2%:%TIME2:~6,2%+09:00"■002▲mnlg-%filename%■03▲タイトル■04▲見出し■05▲動画ID■06▲ >> mnlg-%filename%.md

Makoto

c:
chcp 65001
cd C:\Users\kin213\Desktop\youtubehenkan
@echo off

echo %date%
echo %time%

set yyyy=%date:~0,4%
set mm=%date:~5,2%
set dd=%date:~8,2%

set time2=%time: =0%

set hh=%time2:~0,2%
set mn=%time2:~3,2%
set ss=%time2:~6,2%

set filename=%yyyy%-%mm%%dd%-%hh%%mn%%ss%

@echo off
set TIME2=%TIME: =0%

echo ■001▲date = "%DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2%T%TIME2:~0,2%:%TIME2:~3,2%:%TIME2:~6,2%+09:00"■002▲makoto-%filename%■03▲タイトル■04▲見出し■05▲動画ID■06▲ >> makoto-%filename%.md

Post

c:
chcp 65001
cd C:\Users\kin213\Desktop\youtubehenkan
@echo off

echo %date%
echo %time%

set yyyy=%date:~0,4%
set mm=%date:~5,2%
set dd=%date:~8,2%

set time2=%time: =0%

set hh=%time2:~0,2%
set mn=%time2:~3,2%
set ss=%time2:~6,2%

set filename=%yyyy%-%mm%%dd%-%hh%%mn%%ss%

@echo off
set TIME2=%TIME: =0%

echo ■001▲date = "%DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2%T%TIME2:~0,2%:%TIME2:~3,2%:%TIME2:~6,2%+09:00"■002▲post-%filename%■03▲タイトル■04▲見出し■05▲動画ID■06▲ >> post-%filename%.md

見出し

複数のファイルに対して正規表現を使ってGrepをかけると、Windowsでは動作が安定しないことが多いです。

MIFES(セール時は1万円ぐらいです)のグローバル置換では、かなり安定して置換ができます。

Windows版 テキストエディタ MIFES 10

Hugoの記事ファイルのもとを生成して、さらにMIFESのグローバル置換(下記)で記事をつくります。

「0x06」とは「正規表現で」というMIFES上の記号です。 タブの左が置換対象(~を置換したい)、タブの右が置換目標(~に置換したい)です。 ■05▲と■06▲は余計なもので、■05▲と■06▲との間にYouTubeの動画IDを入れるとレスポンシブな

REPBATCH2=0x06,●YouT記事生成    ●YouT記事生成
REPBATCH2=0x06,■▲YouTube記事  ■▲YouTube記事
REPBATCH2=0x06,■001▲    +++\n
REPBATCH2=0x06,■002▲    \ndraft = true\nslug = "
REPBATCH2=0x06,■01▲ +++\ndate = "2018-03-13T
REPBATCH2=0x06,■02▲ +09:00"\ndraft = true\nslug = "
REPBATCH2=0x06,■03▲ "\ncategories = [""]\ntopics = [""]\ntags = [""]\ntitle = "
REPBATCH2=0x06,■04▲ "\n+++\n\n\n<div id="toc"></div>\n\n<hr>\n\n\n## 
REPBATCH2=0x06,■05▲ \n\n<div style="position:relative;height:0;padding-bottom:56.25%"><iframe src="https://www.youtube.com/embed/
REPBATCH2=0x06,■06▲     ?ecver=2" width="640" height="360" frameborder="0" style="position:absolute;width:100%;height:100%;left:0" allowfullscreen></iframe></div>\n

日時のバッチファイル

date=

@echo off
set TIME2=%TIME: =0%
echo date = "%DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2%T%TIME2:~0,2%:%TIME2:~3,2%:%TIME2:~6,2%+09:00"| clip

lastmod=

@echo off
set TIME2=%TIME: =0%
echo lastmod = "%DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2%T%TIME2:~0,2%:%TIME2:~3,2%:%TIME2:~6,2%+09:00"| clip

プログラマブルキーボード 66キー/78キー「MXチェリー製スイッチ黒軸 / 4倍キー設定可能」

そういったバッチファイルにショートカットキーを割り当てて、プログラマブルキーボードで呼び出すと効率が高まります。

66キー 78キー プログラマブルキーボード チェリー黒軸 | ジェイダブルシステム

Shortkeys (Custom Keyboard Shortcuts) for Firefox

Shortkeysにキーを登録します。 そうすると、プログラマブルキーボードからブラウザ上の操作が

https://addons.mozilla.org/ja/firefox/addon/shortkeys/

下記をインポートしてください。

[{"action":"javascript","blacklist":false,"code":"javascript:prompt('HTML link','<i class=\"fi-web\"></i><a href=\"'+location.href+'\" rel=\"nofollow\" target=\"_blank\">'+document.title+'</a><br>')();","customName":"google3","exported":true,"key":"ctrl+shift+alt+1","open":false,"sites":"*mail.google.com*","sitesArray":["*mail.google.com*"]},{"action":"javascript","blacklist":false,"code":"javascript:prompt('HTML link','<i class=\"fi-social-youtube\"></i><a href=\"'+location.href+'\" rel=\"nofollow\" target=\"_blank\">'+document.title+'</a><br>')();","customName":"youtube2","exported":true,"key":"ctrl+shift+alt+2","open":false,"sites":"*mail.google.com*","sitesArray":["*mail.google.com*"]},{"action":"javascript","blacklist":false,"code":"javascript:prompt('HTML link','<i class=\"fi-social-amazon\"></i><a href=\"'+location.href+'\" rel=\"nofollow\" target=\"_blank\">'+document.title+'</a><br>')();","customName":"amazon","exported":true,"key":"ctrl+shift+alt+3","open":false,"sites":"*mail.google.com*","sitesArray":["*mail.google.com*"]},{"action":"javascript","blacklist":false,"code":"javascript:window.open('https://yomereba.com/blogparts/?&url='+encodeURI(document.location.href));undefined;\n\n\n\n\n\n","customName":"ヨメレバ","exported":true,"key":"ctrl+shift+alt+0","open":false,"sites":"*mail.google.com*","sitesArray":["*mail.google.com*"]},{"action":"javascript","blacklist":false,"code":"javascript:var pi = document.getElementsByTagName('meta');var itemcode;for(i=0;i<pi.length;i++){if(pi[i].getAttribute('property')=='apprakuten:item_code'){itemcode = pi[i].getAttribute('content');break;}}window.open('https://kaereba.com/blogparts/?&url='+encodeURI(document.location.href)+'&itemcode='+itemcode+'&title'+document.title);undefined;\n","customName":"カエレバ","exported":true,"key":"ctrl+shift+alt+9","open":false,"sites":"*mail.google.com*","sitesArray":["*mail.google.com*"]},{"action":"javascript","blacklist":false,"code":"javascript:(function(){var a=document.getElementsByName(\"ASIN.0\")[0]?document.getElementsByName(\"ASIN.0\")[0].value:document.getElementsByName(\"ASIN\")[0]?document.getElementsByName(\"ASIN\")[0].value:\"ASIN\\u304c\\u898b\\u3064\\u304b\\u308a\\u307e\\u305b\\u3093\\u3067\\u3057\\u305f\";location.href=\"https://www.amazon.co.jp/dp/\"+a})();","customName":"Amazon単純化","exported":true,"key":"ctrl+shift+alt+8","open":false,"sites":"*mail.google.com*","sitesArray":["*mail.google.com*"]},{"action":"javascript","blacklist":false,"code":"javascript:(window.open('https://www.yahoo.co.jp/', '_blank');)();\n","customName":"Amazon 新刊","exported":true,"key":"ctrl+shift+alt+4","matchurl":"javascript:(window.open('https://www.yahoo.co.jp/', '_blank');)();","open":false,"sites":"*mail.google.com*","sitesArray":["*mail.google.com*"]},{"action":"gototab","blacklist":false,"customName":"学参ドットコム 新刊","exported":true,"key":"shift+ctrl+alt+f","matchurl":"https://www.gakusan.com/home/newbook.php","open":false,"sites":"*mail.google.com*","sitesArray":["*mail.google.com*"]},{"action":"javascript","blacklist":false,"code":"javascript:prompt('HTML link','<a href=\"'+location.href+'\" rel=\"nofollow\" target=\"_blank\">'+document.title+'</a>')();","customName":"リンク","exported":true,"key":"ctrl+shift+alt+5","open":false,"sites":"*mail.google.com*","sitesArray":["*mail.google.com*"]},{"key":"ctrl+shift+alt+6","action":"javascript","blacklist":false,"sites":"*mail.google.com*","open":false,"code":"javascript:(function(){javascript:(function(){s=location.href;s=''+s.substr(s.search(/(\\/product\\/|\\/dp\\/)/)).split('/')[2].substr(0,10);prompt(unescape('%u77ED%u3044URL%u306F%u4E0B%u8A18%u306E%u901A%u308A%u3067%u3059%u3002'),s);})();})();","exported":true,"sitesArray":["*mail.google.com*"],"customName":"ASIN"},{"key":"ctrl+shift+alt+g","action":"javascript","blacklist":false,"sites":"*mail.google.com*","open":false,"customName":"書籍横断","code":"javascript:( function() { document.location=\"http://book.tsuhankensaku.com/hon/index.php?t=booksearch&q=\" + document.getElementById(\"productTitle\").innerText; })();","exported":true,"sitesArray":["*mail.google.com*"]}]
 
comments powered by Disqus