1
0

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.

コマンドプロンプトでスペースを含むファイルパスを処理する場合

Posted at

先日コマンドプロンプトで処理をしようとした際に、OneDrive上のファイルを読み取ろうとしたところ、以下のエラーが発生した。

ファイルパス(コマンドプロンプト上に入力した内容です):
C:\Users\ユーザー名\OneDrive - ●●\テストフォルダ\対象ファイル.xlsx

エラーメッセージ:
'C:\Users\ユーザー名\OneDrive'は、内部コマンドまたは外部コマンド、可能なプログラムまたはバッチファイルとして認識されていません

OneDrive上のファイルをCドライブに移してパスを変更したところ、正常に処理は完了しましたが
上記のエラーの原因についても、調べてみました。

調べてみたところ、ファイルパスにスペースが含まれていたことが原因でした。
この場合にエラーを避けるには、ダブルクォーテーションで囲むことで解決できるそうで、以下のファイルパスに変更したところ、OneDrive上のファイルでも正常に処理が完了することができました。

修正後のファイルパス(コマンドプロンプト上に入力した内容です):
"C:\Users\ユーザー名\OneDrive - ●●\テストフォルダ\対象ファイル.xlsx"

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?