0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

全角スペースを含むファイルパスをドラッグドロップでbatに渡すとファイルがないと言われる

Last updated at Posted at 2023-12-15

事象

フルパスに全角スペースを含むファイルをドラッグドロップでbatに投げると No such file or directory

原因

%1でファイル名を取る場合、
・全角スペースを含む:全角スペース単位でsplitされて、最初の要素が%1となる。
・半角スペースを含む:splitされず、ダブルコーテで括られた形となる。

なんだこの仕様。

対応

%*で引数全体を取り、ダブルコーテを消す。
ただし、1ファイル前提。

set fullpath=%*
set fullpath=%fullpath:"=%
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?