命令提示符 - 批处理文件 - BAT 文件
Command Prompt - Batch File - BAT File
我想写一个批处理文件,以便给定文件夹中的所有文件都将被解密,即对于指定目录中的每个文件 运行 我在下面写的命令,都使用当前文件名用于输入和输出文件名。
gpg --passphrase "MYPASS52381" -d -o "E:\filename.txt.PGP" "E:\filename.txt"
最好在 for 循环中,来自批处理文件:
@echo off
for %%i in (*.PGP) do gpg --passphrase "MYPASS52381" -d -o "%%~fi" "%%~dpni"
来自命令行:
for %i in (*.PGP) do gpg --passphrase "MYPASS52381" -d -o "%~fi" "%~dpni"
打开命令提示符,(cmd.exe
),运行 for /?
您将在其中看到变量引用:
您现在可以使用以下可选语法(注意,我已将变量更改为小写,以反映您的情况):
%~i - expands %i removing any surrounding quotes (")
%~fi - expands %i to a fully qualified path name
%~di - expands %i to a drive letter only
%~pi - expands %i to a path only
%~ni - expands %i to a file name only
%~xi - expands %i to a file extension only
%~si - expanded path contains short names only
%~ai - expands %i to file attributes of file
%~ti - expands %i to date/time of file
%~zi - expands %i to size of file
换句话说,在这种情况下,例如,%%~dpni
扩展为 %%i
的驱动器、路径和名称,但不包括文件扩展名。
我想写一个批处理文件,以便给定文件夹中的所有文件都将被解密,即对于指定目录中的每个文件 运行 我在下面写的命令,都使用当前文件名用于输入和输出文件名。
gpg --passphrase "MYPASS52381" -d -o "E:\filename.txt.PGP" "E:\filename.txt"
最好在 for 循环中,来自批处理文件:
@echo off
for %%i in (*.PGP) do gpg --passphrase "MYPASS52381" -d -o "%%~fi" "%%~dpni"
来自命令行:
for %i in (*.PGP) do gpg --passphrase "MYPASS52381" -d -o "%~fi" "%~dpni"
打开命令提示符,(cmd.exe
),运行 for /?
您将在其中看到变量引用:
您现在可以使用以下可选语法(注意,我已将变量更改为小写,以反映您的情况):
%~i - expands %i removing any surrounding quotes (")
%~fi - expands %i to a fully qualified path name
%~di - expands %i to a drive letter only
%~pi - expands %i to a path only
%~ni - expands %i to a file name only
%~xi - expands %i to a file extension only
%~si - expanded path contains short names only
%~ai - expands %i to file attributes of file
%~ti - expands %i to date/time of file
%~zi - expands %i to size of file
换句话说,在这种情况下,例如,%%~dpni
扩展为 %%i
的驱动器、路径和名称,但不包括文件扩展名。