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

ファイルの末尾に「_〇〇〇」をつけるbat

Last updated at Posted at 2020-07-19

個人メモ

「_〇〇〇」の場所だけ変えればよいだけ!

※batファイルのあるフォルダ内のファイル全てが対象
※既に「_〇〇〇」が末尾のファイルには追加しない
※ファイル名やフォルダ名に半角スペース、()があるとerrorになる
※共有フォルダなど、管理者権限が必要な場合、batが使えない場面がある

@ECHO OFF
SETlocal ENABLEDELAYEDEXPANSION
REM refrence
REM https://teratail.com/questions/149529
REM https://qiita.com/tomotagwork/items/5b9e08f28d5925d96b5f
REM http://tooljp.com/bat_qa/ECHO-off-errror-3B28.html
REM https://web.plus-idea.net/2016/09/windows-bat-substr/
REM https://qiita.com/plcherrim/items/8edf3d3d33a0ae86cb5c

SET addStr=_〇〇〇
FOR %%i IN (*) DO (
    SET file1=%%~ni
    SET file2=!file1:~-0,-3!%addStr%%%~xi
    IF NOT %%i==!file2! (
        REN %%i %%~ni%addStr%%%~xi
     )
)
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?