.bat 对指定文件夹中的文件做出反应,如何使其对拖到其上的文件做出反应?

发布于 2024-10-09 11:40:50 字数 1495 浏览 0 评论 0原文

我下载了一个批量铃声转换器,它允许我批量转换程序文件夹\mp3文件夹中的文件。我喜欢 .bat,但我想修改它,以便它不会对 \mp3 文件夹中的文件做出反应,而是对拖到 .bat 文件上的文件做出反应。我希望我可以将多个文件拖到上面。

无论如何这可能吗?提前非常感谢。我认为这是下面 .bat 中的简单代码编辑,但我并不是 Windows .bat 文件的真正有经验的用户。

以下是 .bat 文件的代码:

@echo off
echo **************************************************************
echo *  Convert mp3 into m4r                                      *
echo *                                                            *
echo *                                       by gary cheung       *
echo *                                                            *
echo *       This script only convert mp3 into m4r and you should *
echo *             unload the m4r using itunes or other methods   *
echo **************************************************************
echo.   
echo There are no guarantees on running this software. 
echo You may even damage your iPhone with it.
echo Consider yourself warnned!
echo.
echo.
echo Are you ready? (To cancel press CTRL+C, to go on presss any key) 
pause
echo.

copy "mp3\*.mp3" "temp\*."

for %%x in (temp\*.*) do start /w  besweet -S --silent -p -core( -input "%%x" -output "%%x".1 -2ch ) 
for %%x in (temp\*.1) do start /w  faac -w -o "%%x".m4r "%%x"

copy "temp\*.m4r" "m4r\*.*"

del /Q temp\*.*



echo ************* Finish
echo.
echo.
echo Great!
echo.
echo BTW, I'm Gary Cheung who live in Hong Kong. :P
pause

如果您需要整个包,我已将其上传到此处

I downloaded a batch ringtone converter which allows me to batch convert files in the program's folder\mp3 folder. I like the .bat but I want to modify it so that it doesn't react to files in the \mp3 folder, but in files that are dragged onto the .bat file. And I want that I can drag MULTIPLE files onto it.

Is this possible in anyway? Thanks A LOT in advance. I suppose it's a simple code edit in the .bat below but I am not really an experienced user of Windows .bat files.

Here is the .bat file's code:

@echo off
echo **************************************************************
echo *  Convert mp3 into m4r                                      *
echo *                                                            *
echo *                                       by gary cheung       *
echo *                                                            *
echo *       This script only convert mp3 into m4r and you should *
echo *             unload the m4r using itunes or other methods   *
echo **************************************************************
echo.   
echo There are no guarantees on running this software. 
echo You may even damage your iPhone with it.
echo Consider yourself warnned!
echo.
echo.
echo Are you ready? (To cancel press CTRL+C, to go on presss any key) 
pause
echo.

copy "mp3\*.mp3" "temp\*."

for %%x in (temp\*.*) do start /w  besweet -S --silent -p -core( -input "%%x" -output "%%x".1 -2ch ) 
for %%x in (temp\*.1) do start /w  faac -w -o "%%x".m4r "%%x"

copy "temp\*.m4r" "m4r\*.*"

del /Q temp\*.*



echo ************* Finish
echo.
echo.
echo Great!
echo.
echo BTW, I'm Gary Cheung who live in Hong Kong. :P
pause

And if you need the whole package, I've uploaded it here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

记忆之渊 2024-10-16 11:40:50

如果将文件拖放到批处理脚本(.BAT 文件)中,则批处理文件将以拖放项作为第一个参数运行。

所以你需要做的就是处理第一个参数,用%1表示。

对于初学者,在 .BAT 文件中,在顶部附近添加以下行:

echo The Drag-Drop file is %1

然后对其进行测试,以确保您可以拖放到批处理文件中。

我不确定批处理脚本是否/如何处理多个拖放,但请检查后续参数(%2、%3、%4...)以查看这是否适用于多文件拖放。

If you drag-drop a file to a batch-script (.BAT file), the batch-file will be run with the drag-drop item as the first parameter.

So all you need to do is process the first parameter, which is indicated by %1.

For starters, in your .BAT file, add the line near the top:

echo The Drag-Drop file is %1

Then test that to make sure you can drag-drop to your batch file.

I am not sure if/how batch-scripts handle multiple drag-drop, but check the subsequent parameters (%2, %3, %4...) to see if that works for multi-file drag-drop.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文