[英]BATCH script, parsing several files with different extensions
I need to automate a process creating a BATCH script. 我需要自动化创建BATCH脚本的过程。 I must say my knowledge about BATCH scripting and programming in general is very very basic but i'm trying to learn.
我必须说,我通常对BATCH脚本和编程的知识非常基础,但是我正在尝试学习。
I got an .exe with the next command line: 我在下一个命令行中得到了一个.exe:
decrypt.exe -k [key of decrypt] -f [file for decrypt] -e [extension of file with dot]
example: decrypt.exe -k decrypt.key -f file.pdf -e .pdf
And i need to run it to decrypt thousands of files with different extensions. 我需要运行它来解密具有不同扩展名的数千个文件。
My idea is to run the script on c:\\ and recursively let it decrypt all the files. 我的想法是在c:\\上运行脚本,然后递归地让它解密所有文件。
Also, if the file has an extension .lol i need to rename the file removing only that extension, for example; 另外,如果文件扩展名为.lol,则我需要重命名该文件,例如,仅删除该扩展名。 file.pdf.lol to file.pdf.
file.pdf.lol至file.pdf。 This is not as important, since i can just run a new script later.
这并不重要,因为我以后可以运行新脚本。
So far this is what i got: 到目前为止,这就是我得到的:
FOR /R %%f IN (*.lol) DO decrypt.exe -k "decrypt.key" -f "%%f" -e "%%~xf"
And after some investigation, i found the command FORFILES: 经过一番调查,我发现了命令FORFILES:
FORFILES /m *.lol /s /C "decrypt.exe -k decrypt.key -f @file -e @ext"
I got ALL the extensions writted on a .txt file, so if the script can read the extensions from that file would be great but i can't figure how. 我将所有扩展名都写在.txt文件中,因此,如果脚本可以从该文件读取扩展名,那将是不错的选择,但我不知道怎么做。
Any help would be really appreciated! 任何帮助将非常感激!
Thanks! 谢谢!
FOR /R %%f IN (*.lol) DO ren "%%f" "%%~nf"
FOR /R %%f IN (*.*) DO decrypt.exe -k "decrypt.key" -f "%%f" -e "%%~xf"
should work for you. 应该为您工作。
The first should rename the files from *.lol
to *
and then the second runs your decrypt
according to your original code. 第一个应将文件从
*.lol
重命名为*
,然后第二个将根据原始代码运行decrypt
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.