Batch file 命令提示符-批处理文件-BAT文件

Batch file 命令提示符-批处理文件-BAT文件,batch-file,encryption,cmd,command-prompt,Batch File,Encryption,Cmd,Command Prompt,我想编写一个批处理文件,以便对给定文件夹中的所有文件进行解密,即对于指定目录中的每个文件,运行我在下面编写的命令,使用当前文件名作为输入和输出文件名 gpg --passphrase "MYPASS52381" -d -o "E:\filename.txt.PGP" "E:\filename.txt" 这可能是最好的for循环,来自batchfile: @echo off for %%i in (*.PGP) do gpg --passphrase "MYPASS52381" -d -o "%

我想编写一个批处理文件,以便对给定文件夹中的所有文件进行解密,即对于指定目录中的每个文件,运行我在下面编写的命令,使用当前文件名作为输入和输出文件名

gpg --passphrase "MYPASS52381" -d -o "E:\filename.txt.PGP" "E:\filename.txt"

这可能是最好的for循环,来自batchfile:

@echo off
for %%i in (*.PGP) do gpg --passphrase "MYPASS52381" -d -o "%%~fi" "%%~dpni"
从cmdline:

for %i in (*.PGP) do gpg --passphrase "MYPASS52381" -d -o "%~fi" "%~dpni"
打开命令提示符(
cmd.exe
),运行
获取/?
,您将看到变量引用:

您现在可以使用以下可选语法(注意,我已将变量更改为小写,以反映您的场景):


换句话说,在本例中,例如,
%%~dpni
扩展为驱动器、
%%i的路径和名称,但不包括文件扩展名。

从batchfile开始,最好使用for循环:

@echo off
for %%i in (*.PGP) do gpg --passphrase "MYPASS52381" -d -o "%%~fi" "%%~dpni"
从cmdline:

for %i in (*.PGP) do gpg --passphrase "MYPASS52381" -d -o "%~fi" "%~dpni"
打开命令提示符(
cmd.exe
),运行
获取/?
,您将看到变量引用:

您现在可以使用以下可选语法(注意,我已将变量更改为小写,以反映您的场景):


换句话说,在本例中,例如,
%%~dpni
扩展到驱动器、
%%i的路径和名称,但不包括文件扩展名。

复制文本并粘贴到此处。复制文本并粘贴到此处。~f&~dpn是什么意思?。我在哪里可以获得更多的信息或材料来编写这样的查询。更新的答案。~f&~dpn是什么意思?。我在哪里可以得到更多的信息或材料来编写这样的查询。更新的答案。