![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-11-11 14:33 |
47,815 topics / 349,930 posts / today 0 new / 48,291 members |
| DOS批处理 & 脚本技术(批处理室) » How to implement the function of calling a bat file through the right-click menu to move files |
| Printable Version 3,857 / 43 |
| Floor31 pinghu | Posted 2008-02-07 23:46 |
| 中级用户 Posts 130 Credits 307 | |
Originally posted by slore at 2008-2-6 12:54 PM: What the 17th floor said is correct. If you use * to apply to files, to apply to folders you need to use or folder, but you cannot use directory and folder at the same time. Using AllFileSystemObject can apply to both files and folders. The registry is really picky, it has to ensure both comprehensive functions and no redundancy and overlap in the key values! What is the parameter format and function of "%%~dpnxi" in the line "call :sub1 "%%~dpnxi""? |
|
| Floor32 pinghu | Posted 2008-02-07 23:51 |
| 中级用户 Posts 130 Credits 307 | |
|
What the person upstairs said about the log function, I also completely don't know how to do it. I'm too inexperienced.
There are still many grammatical errors in what I write, and I'm not familiar with the syntax of batch processing. For example, can the jump label within the scope of the for statement be recognized? |
|
| Floor33 pinghu | Posted 2008-02-08 00:00 |
| 中级用户 Posts 130 Credits 307 | |
|
Why can directly selecting a folder achieve moving up, but selecting a folder cannot? It's also plagiarizing sub1, headache
|
|
| Floor34 pinghu | Posted 2008-02-08 11:36 |
| 中级用户 Posts 130 Credits 307 | |
|
I used the 'dir /b' mentioned by the person above, and it worked successfully. I can extract shelled files and folders, and it's a success. I've learned a lot. Now I'll post the complete batch again for everyone to use.
Installation program @echo off call :%* 2>nul || goto setup goto :eof :Sub1 rem Move to parent directory if not defined str set "str=%~nx1" if not exist "..\%~nx1" (move "%str%" "..\%~nx1" && set "str=" && goto :eof) call :Sub1 "%~n1_New%~x1" goto :eof :Sub2 rem Unshell cd "%~1" for /f "delims=" %%i in ('dir /b') do call :Sub1 "%%~dpnxi" goto :eof :setup reg add "hkcr\AllFilesystemObjects\shell\Move to Parent Directory\command" /f /t reg_sz /v "" /d "\"%~0\" Sub1 \"%%1\"" reg add "hkcr\directory\shell\Unshell\command" /f /t reg_sz /v "" /d "\"%~0\" Sub2 \"%%1\"" goto :eof Uninstallation program reg delete "hkcr\directory\shell\Unshell" /f reg delete "hkcr\AllFilesystemObjects\shell\Move to Parent Directory" /f |
|
| Floor35 3742668 | Posted 2008-02-08 12:16 |
| 荣誉版主 Posts 718 Credits 2,013 | |
|
Very Good!
However, just using dir /b cannot copy hidden files. Also, why not put the uninstall part in the setup? In it, judge whether there are relevant registry items and then decide whether to install or uninstall. The most important thing is how much you have gained in this post? Can you write code with your own style based solely on the idea without looking at the reference? For example, what is the actual reason for the problem mentioned in your previous 12F? What is the connection between the content of the value in the registry and the batch processing? Why are there quotes in some places and not in others? You can try to solve these problems by yourself. If you don't understand something, you can post a reply to seek hints. |
|
| Floor36 pinghu | Posted 2008-02-08 13:34 |
| 中级用户 Posts 130 Credits 307 | |
|
@echo off
call :%* 2>nul || goto choice goto :eof :Sub1 rem Move to parent directory if not defined str set "str=%~nx1" if not exist "..\%~nx1" (move "%str%" "..\%~nx1" && set "str=" && goto :eof) call :Sub1 "%~n1_New%~x1" goto :eof :Sub2 rem Unpack pushd "%~1" for /f "delims=" %%i in ('dir /a /b') do call :Sub1 "%%~dpnxi" popd rd "%~1" goto :eof :choice set /p dd=Install A, Uninstall X, Exit T: if "%dd%"=="a" goto setup if "%dd%"=="A" goto setup if "%dd%"=="x" goto unistall if "%dd%"=="X" goto unistall if "%dd%"=="t" goto :eof if "%dd%"=="T" (goto :eof) else echo Re-enter &goto choice goto :eof :setup reg add "hkcr\AllFilesystemObjects\shell\Move to Parent Directory\command" /f /t reg_sz /v "" /d "\"%~0\" Sub1 \"%%1\"" reg add "hkcr\directory\shell\Unpack\command" /f /t reg_sz /v "" /d "\"%~0\" Sub2 \"%%1\"" goto :eof :unistall reg delete "hkcr\directory\shell\Unpack" /f reg delete "hkcr\AllFilesystemObjects\shell\Move to Parent Directory" /f goto :eof Now the uninstall is also added, and the /a parameter is added to dir. I still don't know the usage of call in this text, and how %1 is passed in the registry and batch processing. |
|
| Floor37 pinghu | Posted 2008-02-08 13:41 |
| 中级用户 Posts 130 Credits 307 | |
|
Adding dir /a /b still can't move hidden files
|
|
| Floor38 pinghu | Posted 2008-02-08 13:50 |
| 中级用户 Posts 130 Credits 307 | |
|
Can the two sentences "if "%dd%"=="a" goto setup" and "if "%dd%"=="A" goto setup" be written as one sentence?
|
|
| Floor39 slore | Posted 2008-02-08 15:59 |
| 铂金会员 Posts 2,478 Credits 5,212 | |
| Floor40 pinghu | Posted 2008-02-08 17:17 |
| 中级用户 Posts 130 Credits 307 | |
|
I've figured out a problem. When running a batch file, you can add parameters. When calling a subroutine with the call label, you can also add parameters.
|
|
| Floor41 pinghu | Posted 2008-02-08 17:23 |
| 中级用户 Posts 130 Credits 307 | |
|
An important issue for beginners to learn
It seems that after /?, you are not familiar with the format of the application command For example if "%dd%"=="a" goto setup Can the two sentences if "%dd%"=="A" goto setup be written as one sentence? This problem I used if "%dd%"=="a" ^| "%dd%"=="A" goto setup The syntax is incorrect ah |
|
| Floor42 pinghu | Posted 2008-02-08 18:00 |
| 中级用户 Posts 130 Credits 307 | |
|
Is there really no logical operator without the assignment function? The previous question can be solved with the /i parameter. Can we use one statement to judge that the value of dd is equal to one of a, b, c to meet the condition?
|
|
| Floor43 3742668 | Posted 2008-02-08 18:22 |
| 荣誉版主 Posts 718 Credits 2,013 | |
|
Why is there still interaction? In the setup, first test if there is installation information in the registry. If there is, uninstall automatically; if not, install automatically. The structure should be clearer and more straightforward. |
|
| Floor44 pinghu | Posted 2008-02-09 12:42 |
| 中级用户 Posts 130 Credits 307 | |
|
Thanks to the great support of 3742668, if you hadn't helped me write it, I couldn't have done it. In short, it's a complete success! It's even better than I expected!! Thanks again to 3742668!!
|
|
| Prev 1 2 3 |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |