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

経緯

いろんなパスからファイル取得する割に整理されていなかったりするので欲しいファイルを記述して取ってくるバッチ作成
残して置いていつでも使えるように記事にした。

FileCopy.bat
@echo off
setlocal enabledelayedexpansion

rem リストファイルのパス
set "listFilePath=C:\Work\list_file.txt"

rem ネットワークドライブのパス
set "drivePath=\\Fileserver\log"

rem 日付のフォーマット
set "dateFormat="

rem 一時ディレクトリにコピーする先のパス
set "destinationPath=C:\Work"

rem リストファイルからファイル名を取得してファイルをコピー
for /f %%i in (%listFilePath%) do (
    rem ファイルのフルパスを構築
    set "sourceFilePath=!drivePath!\%%i!dateFormat!.*"
    
    rem ファイルをコピー
    copy "!sourceFilePath!" "%destinationPath%" /Y
)

endlocal
pause

コメント多めに書き残したので特別に説明とか書いておかなくても困らないはず
1
0
2

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?