14
10

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 5 years have passed since last update.

Resolve-Pathでファイルのフルパス取得

Last updated at Posted at 2015-04-30

Powershellでファイル一覧はGet-ItemやGet-Childrenを使います。
これはあくまでファイルの一覧であってファイルのフルパス一覧ではない。

ファイルのフルパス一覧が欲しい場合には、
Resolve-Pathを使います。

##Resolve-Pathを使う

Resolve-Path
PS > Resolve-Path FileName
Path
----
C:\Users\yusuke\FileName

ワイルドカードも使えます。

ワイルドカードを使って複数ファイルのパスを取得

PS > Resolve-Path Folder\*
Path
----
C:\Users\yusuke\File1
C:\Users\yusuke\File2
C:\Users\yusuke\File3

私はこんな風に使います。

フォルダー内のCSVファイルを全てインポート
PS > $files = Resolve-Path resources\*.csv
PS > $files
Path
----
C:\Users\yusuke\title.csv
C:\Users\yusuke\firstname.csv
C:\Users\yusuke\familyname.csv

PS > $data = Import-Csv $files
PS > $data | Format-Table
ID   Data
---  ----
 1   Mister
 2   Yusuke
 3   Arakawa

##参考サイト
Resolve-Path  Microsoft TechNet

14
10
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
14
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?