China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-02 20:58
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to implement the function of calling a bat file through the right-click menu to move files View 2,895 Replies 43
Original Poster Posted 2008-02-04 16:51 ·  中国 吉林 吉林市 联通
中级用户
★★
Credits 307
Posts 130
Joined 2008-02-01 21:29
18-year member
UID 109981
Gender Male
Status Offline
Function 1: When multiple files and folders are selected with the right mouse button, the "Move to Parent Directory" command appears in the right-click menu. The result of execution is to move the selected files and folders to the parent directory. If there is a file name conflict, it will be automatically renamed.

Function 2: When multiple folders are selected with the right mouse button, the "Unpack" command appears in the right-click menu. The result of execution is to move all contents in the selected folder to the current directory and then delete the selected folder. If there is a file name conflict, it will be automatically renamed.

I am using XP. If these two functions can be realized, it will be very useful. The problem is a bit difficult, and I hope everyone can study it! If someone can write a single BAT file to realize these two functions, I will be extremely impressed. If a single BAT file cannot be realized, it is also good to use a combination of BAT and reg. Thank you everyone!
Floor 2 Posted 2008-02-04 17:37 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Renaming is a bit troublesome... Moving is not difficult.
Floor 3 Posted 2008-02-05 11:14 ·  中国 吉林 吉林市 联通
中级用户
★★
Credits 307
Posts 130
Joined 2008-02-01 21:29
18-year member
UID 109981
Gender Male
Status Offline
The difficulty is whether it is to ensure that after renaming, it will not conflict with other files, right?
Floor 4 Posted 2008-02-05 11:41 ·  中国 湖北 荆门 电信
荣誉版主
★★★
Credits 2,013
Posts 718
Joined 2006-02-18 07:07
20-year member
UID 50550
Status Offline
It's not difficult to implement a single file, it's just that I'm too lazy to do the manual work. It is suggested that you learn about Wunaaihe's sendto+, as well as the right-click menu issues that have been discussed many times in this forum. It should be very simple to implement.
Floor 5 Posted 2008-02-05 19:31 ·  中国 吉林 吉林市 联通
中级用户
★★
Credits 307
Posts 130
Joined 2008-02-01 21:29
18-year member
UID 109981
Gender Male
Status Offline
I can't find the post mentioned upstairs. Can someone give a reference address?
Floor 6 Posted 2008-02-05 19:49 ·  中国 吉林 吉林市 联通
中级用户
★★
Credits 307
Posts 130
Joined 2008-02-01 21:29
18-year member
UID 109981
Gender Male
Status Offline
Suppose when I select the file, I use %1 to represent the file, and use the command cd %~dp1 to enter the folder. Then when I use xcopy /s/q/-y %1 ..\ to copy the file, there is a situation where the file is not found. How to handle it?
Floor 7 Posted 2008-02-05 19:55 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Why not use move?

Is your file path has space?
Floor 8 Posted 2008-02-05 20:17 ·  中国 吉林 吉林市 联通
中级用户
★★
Credits 307
Posts 130
Joined 2008-02-01 21:29
18-year member
UID 109981
Gender Male
Status Offline
Floor 9 Posted 2008-02-05 20:20 ·  中国 吉林 吉林市 联通
中级用户
★★
Credits 307
Posts 130
Joined 2008-02-01 21:29
18-year member
UID 109981
Gender Male
Status Offline
How to use the move command with parameters to specify all files and folders under a specified path?
Floor 10 Posted 2008-02-05 20:35 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
It should be *.*.

If there are spaces, you need to enclose it in quotes...

Don't execute it directly in your script, it's better to echo it first...
Floor 11 Posted 2008-02-05 20:57 ·  中国 吉林 吉林市 联通
中级用户
★★
Credits 307
Posts 130
Joined 2008-02-01 21:29
18-year member
UID 109981
Gender Male
Status Offline
When selecting a file, the call to %1 returns an empty value. Why is that?郁闷啊,can't give the full code, at least give some hints啊
Floor 12 Posted 2008-02-05 21:48 ·  中国 吉林 吉林市 联通
中级用户
★★
Credits 307
Posts 130
Joined 2008-02-01 21:29
18-year member
UID 109981
Gender Male
Status Offline
It seems that everyone hasn't attached importance to my post yet. I think it's because everyone thinks the difficulty lies in renaming. Moving files seems very easy. When you test it personally, you will find that when you select several files, call a bat file in the registry command line, the bat doesn't know what files you selected, and %1 doesn't work here. Then you can't continue. Interestingly, when a directory is selected, %1 can return the current path. That is to say, the second function is easier to implement than the first function (temporarily not considering renaming). If the problem is changed to "adding cmd or formatting in the right-click menu, I wouldn't bother to come here to ask questions."
Floor 13 Posted 2008-02-05 22:17 ·  中国 吉林 吉林市 联通
中级用户
★★
Credits 307
Posts 130
Joined 2008-02-01 21:29
18-year member
UID 109981
Gender Male
Status Offline
Before the problem is solved, I don't want the post to sink. The fun can also be obtained while solving the problem.
Floor 14 Posted 2008-02-05 22:36 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Floor 15 Posted 2008-02-05 22:39 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Temporarily uploaded it to the space.
If you can't see the picture, I'll find the address again...

The forum's upload system is too frustrating~
Forum Jump: