7
12

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.

バッチファイルにドラッグアンドドロップした時のファイル名の扱い方

Last updated at Posted at 2019-09-10

%1でファイル名を取得
%~n1で拡張子より前のファイル名を取得
%~p1は上記の%~n1にパスを含む

例)拡張子をdatに変更するコマンド

rename %1 %~n1.dat

例)epsやpsファイルをpdfに変換するコマンド

gswin32c -dNOPAUSE -dBATCH -dEPSCrop -sDEVICE=pdfwrite -sProcessColorModel=DeviceCMYK -dPDFSETTINGS=/prepress -sOutputFile=%~p1.pdf -f %1

参考サイト】
【Windows】バッチファイルの引数 at softelメモ

複数ファイルをバッチファイルにドラッグアンドドロップの場合

@echo off
for %%f in (%*) do (
gswin32c -dNOPAUSE -dBATCH -dGraphicsAlphaBits=4 -dEPSCrop -sDEVICE=jpeg -r500 -sOutputFile=%%~pnf.jpg -f %%~pnxf
)

【参考サイト】
ドラッグ&ドロップでファイル名を取得する | 初心者SEのとりあえずメモ日記

7
12
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
7
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?