|
evilangell
初级用户
 
积分 32
发帖 32
注册 2008-4-18
状态 离线
|
『楼 主』:
批处理选择性复制文件一直没成功,求解决
使用 LLM 解释/回答一下
选择性复制文件.BAT
功能:
1:如果此批处理还未运行,我拖放一个文件(或几个文件)到这个P处理图标上,然后可以根据选择将这个文件(或这几个文件)复制到指定位置,如按1复制到C盘根目录,按2复制到c:\windows目录,按3退出。
2:如果我已经将这个批处理双击,那么,我拖放一个文件(或几个文件)到这个P处理上窗口上,然后可以根据选择将这个文件(或这几个文件)复制到指定位置,如按1复制到C盘根目录,按2复制到c:\windows目录,按3退出。
小弟试了好久一直没成功,请大牛帮忙一下,谢谢
Selectively Copy Files.BAT
Function:
1: If this batch processing has not been run yet, I drag and drop a file (or several files) onto this P processing icon, and then I can copy this file (or these several files) to the specified location according to the selection, such as pressing 1 to copy to the root directory of the C drive, pressing 2 to copy to the c:\windows directory, pressing 3 to exit.
2: If I have double-clicked this batch processing, then I drag and drop a file (or several files) onto this P processing window, and then I can copy this file (or these several files) to the specified location according to the selection, such as pressing 1 to copy to the root directory of the C drive, pressing 2 to copy to the c:\windows directory, pressing 3 to exit.
Little brother has tried for a long time and has not succeeded, please big bull help, thank you
|
|
2010-10-20 10:16 |
|
|
evilangell
初级用户
 
积分 32
发帖 32
注册 2008-4-18
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
:again
echo.
if "%~f1" neq "" (set FullPathName=%~f1) else (goto ADD)
:ADD
set FullPathName=%~f1
ECHO %FullPathName%
@set choice
@set /p choice= 请选择【1→windows目录下】,【2→system32目录下】,【3→C盘】
echo.
set FullPathName=%~f1
::IF NOT "%Choice%"=="" SET Choice=%Choice:~0,1%
PAUSE
echo.
if /i "%choice%"=="1" goto windows
if /i "%choice%"=="2" goto system32
if /i "%choice%"=="3" goto CC
echo.
ECHO 选项不对,按任意键退出
pause
exit
:windows
ECHO "%FullPathName%" 将被复制到windows目录下
COPY "%FullPathName%" %SYSTEMROOT%\
pause
goto again
:system32
ECHO "%FullPathName%" 将被复制到system32目录下
COPY "%FullPathName%" %SYSTEMROOT%\system32\
pause
goto again
:CC
ECHO "%FullPathName%" 将被复制到C盘
COPY "%FullPathName%" C:\
pause
goto again
这是草稿,乱的很,大牛别见笑
:
:again
echo.
if "%~f1" neq "" (set FullPathName=%~f1) else (goto ADD)
:ADD
set FullPathName=%~f1
ECHO %FullPathName%
@set choice
@set /p choice= Please select , ,
echo.
set FullPathName=%~f1
::IF NOT "%Choice%"=="" SET Choice=%Choice:~0,1%
PAUSE
echo.
if /i "%choice%"=="1" goto windows
if /i "%choice%"=="2" goto system32
if /i "%choice%"=="3" goto CC
echo.
ECHO Incorrect option, press any key to exit
pause
exit
:windows
ECHO "%FullPathName%" will be copied to the windows directory
COPY "%FullPathName%" %SYSTEMROOT%\
pause
goto again
:system32
ECHO "%FullPathName%" will be copied to the system32 directory
COPY "%FullPathName%" %SYSTEMROOT%\system32\
pause
goto again
:CC
ECHO "%FullPathName%" will be copied to the C drive
COPY "%FullPathName%" C:\
pause
goto again
This is a draft, very messy, don't laugh at the big guys
|
|
2010-10-20 10:19 |
|
|
evilangell
初级用户
 
积分 32
发帖 32
注册 2008-4-18
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
如果不能拖放多个文件,拖放一个文件也行
If you can't drag and drop multiple files, it's okay to drag and drop one file.
|
|
2010-10-20 13:37 |
|
|
evilangell
初级用户
 
积分 32
发帖 32
注册 2008-4-18
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
@title复制文件到指定路径下 &@color f3&CLS&echo.
:again
@echo.
@if "%~f1" neq "" (set FullPathName="%~f1" &goto Zhijie) else (goto InWindowns)
:InWindowns
@set /p choice=请拖放一个需要被复制的文件到本出口内(拖进来后请按回车):
@set FullPathName=%choice%
@echo.
:Zhijie
@set /p choice=[1→windows目录下], [2→system32目录下], [3→C盘根目录], [Q→EXIT]
@IF NOT "%Choice%"=="" SET Choice=%Choice:~0,1%
@echo.
@if /i "%choice%"=="1" goto windows
@if /i "%choice%"=="2" goto system32
@if /i "%choice%"=="3" goto C_Disk
@if /i "%choice%"=="q" EXIT
@if /i "%choice%"=="Q" EXIT
::过滤因直接回车而误复制文件
@echo 【!您还未拖入任何文件!】
@goto again
:windows
@ECHO %FullPathName%已被复制到windows目录下
@COPY %FullPathName% %SYSTEMROOT%\
@pause
@goto again
:system32
@ECHO %FullPathName%已被复制到system32目录下
@COPY %FullPathName% %SYSTEMROOT%\system32\
@pause
@goto again
:C_Disk
@ECHO %FullPathName%已被复制到C盘
::if exist %FullPathName% (echo 文件已存在 &goto again) else (@COPY %FullPathName% C:\)
@COPY %FullPathName% C:\
@pause
@goto again
复制单个文件已经没问题。
有几个小缺陷:
1,没判断文件已经存在的情况
2,见图,第一次拖入文件后成功复制后,如果空按回车键,会出现如图情况,感觉选择的变量没被清空,但我加入@set /p choice=“”,没法清空。但不影响使用,望高手能来完善!
@title Copy file to specified path &@color f3&CLS&echo.
:again
@echo.
@if "%~f1" neq "" (set FullPathName="%~f1" &goto Zhijie) else (goto InWindowns)
:InWindowns
@set /p choice=Please drag and drop a file to be copied into this exit (press Enter after dragging in):
@set FullPathName=%choice%
@echo.
:Zhijie
@set /p choice=, , ,
@IF NOT "%Choice%"=="" SET Choice=%Choice:~0,1%
@echo.
@if /i "%choice%"=="1" goto windows
@if /i "%choice%"=="2" goto system32
@if /i "%choice%"=="3" goto C_Disk
@if /i "%choice%"=="q" EXIT
@if /i "%choice%"=="Q" EXIT
::Filter the situation of mistakenly copying files due to direct pressing Enter
@echo 【!You haven't dragged any file yet!】
@goto again
:windows
@ECHO %FullPathName% has been copied to the windows directory
@COPY %FullPathName% %SYSTEMROOT%\
@pause
@goto again
:system32
@ECHO %FullPathName% has been copied to the system32 directory
@COPY %FullPathName% %SYSTEMROOT%\system32\
@pause
@goto again
:C_Disk
@ECHO %FullPathName% has been copied to the C drive
::if exist %FullPathName% (echo File already exists &goto again) else (@COPY %FullPathName% C:\)
@COPY %FullPathName% C:\
@pause
@goto again
Copying a single file is already okay.
There are a few minor flaws:
1. No judgment on the situation where the file already exists
2. As shown in the picture, after the first time a file is dragged in and successfully copied, if you press Enter blankly, the situation as shown in the picture will occur. It feels that the selected variable is not cleared, but I added @set /p choice=“”, which cannot clear it. But it doesn't affect use. Hope experts can improve it!
|
|
2010-10-20 16:48 |
|
|
evilangell
初级用户
 
积分 32
发帖 32
注册 2008-4-18
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
图传不上,还是我复制过来吧
以下是cmd.EXE里复制过来的:
请拖放一个需要被复制的文件到本出口内(拖进来后请按回车):"C:\Documents and Settin
gs\Administrator\桌面\欧姆龙.T"
[1→windows目录下], [2→system32目录下], [3→C盘根目录], [Q→EXIT] 3
"C:\Documents and Settings\Administrator\桌面\欧姆龙.T"已被复制到C盘
已复制 1 个文件。
请按任意键继续. . .
请拖放一个需要被复制的文件到本出口内(拖进来后请按回车):
[1→windows目录下], [2→system32目录下], [3→C盘根目录], [Q→EXIT]
3已被复制到C盘
系统找不到指定的文件。
请按任意键继续. . .
请拖放一个需要被复制的文件到本出口内(拖进来后请按回车):
[1→windows目录下], [2→system32目录下], [3→C盘根目录], [Q→EXIT]
3已被复制到C盘
系统找不到指定的文件。
请按任意键继续. . .
The picture can't be uploaded, so I'll just copy it over.
The following is copied from cmd.EXE:
Please drag and drop a file that needs to be copied into this exit (press Enter after dragging it in): "C:\Documents and Settin
gs\Administrator\Desktop\OMRON.T"
, , , 3
"C:\Documents and Settings\Administrator\Desktop\OMRON.T" has been copied to drive C
1 file has been copied.
Press any key to continue. . .
Please drag and drop a file that needs to be copied into this exit (press Enter after dragging it in):
, , ,
3 has been copied to drive C
The system cannot find the specified file.
Press any key to continue. . .
Please drag and drop a file that needs to be copied into this exit (press Enter after dragging it in):
, , ,
3 has been copied to drive C
The system cannot find the specified file.
Press any key to continue. . .
|
|
2010-10-20 16:52 |
|
|
qinchun36
高级用户
    据说是李先生
积分 609
发帖 400
注册 2008-4-23
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
@echo off
title 复制文件到指定路径下
color 17&cls&echo.
if == goto DoOneByOne
:DoForEach
if == goto End
echo 文件 %1
call :GetChoice
if /i == goto End
call :CopyOneFile %1
shift /1
goto DoForEach
:DoOneByOne
echo.&echo 请拖放一个需要被复制的文件到本窗口内(拖进来后请按回车):
set "fn="
set /p fn=
if == goto DoOneByOne
call :GetChoice
if /i == goto End
call :CopyOneFile %fn%
goto DoOneByOne
:End
echo === 程序结束 ===
pause>nul
goto EOF
::=========== END ===========
:GetChoice
echo.&echo →WINDOWS目录 →SYSTEM32目录 →C盘根目录 →退出
set "choice="
set /p choice=
if /i == goto GetChoice
set "loc="
if /i == set "loc=%SYSTEMROOT%\"
if /i == set "loc=%SYSTEMROOT%\system32\"
if /i == set "loc=C:\"
if == set "choice=Q"
goto EOF 2>nul
:CopyOneFile
cls&echo.
if exist "%loc%\%~nx1" (
echo *** "%loc%%~nx1" 已存在 ***
) else (
copy %1 "%loc%" 1>nul&&echo 成功复制 "%~nx1" 到 "%loc%"
)
echo.
goto EOF 2>nul
Last edited by qinchun36 on 2010-10-22 at 16:09 ]
```
@echo off
title Copy files to specified path
color 17&cls&echo.
if == goto DoOneByOne
:DoForEach
if == goto End
echo File %1
call :GetChoice
if /i == goto End
call :CopyOneFile %1
shift /1
goto DoForEach
:DoOneByOne
echo.&echo Please drag and drop a file to be copied into this window (press Enter after dragging it in):
set "fn="
set /p fn=
if == goto DoOneByOne
call :GetChoice
if /i == goto End
call :CopyOneFile %fn%
goto DoOneByOne
:End
echo === Program ended ===
pause>nul
goto EOF
::=========== END ===========
:GetChoice
echo.&echo →WINDOWS directory →SYSTEM32 directory →Root directory of drive C →Exit
set "choice="
set /p choice=
if /i == goto GetChoice
set "loc="
if /i == set "loc=%SYSTEMROOT%\"
if /i == set "loc=%SYSTEMROOT%\system32\"
if /i == set "loc=C:\"
if == set "choice=Q"
goto EOF 2>nul
:CopyOneFile
cls&echo.
if exist "%loc%\%~nx1" (
echo *** "%loc%%~nx1" already exists ***
) else (
copy %1 "%loc%" 1>nul&&echo Successfully copied "%~nx1" to "%loc%"
)
echo.
goto EOF 2>nul
Last edited by qinchun36 on 2010-10-22 at 16:09 ]
```
|
|
2010-10-21 18:13 |
|
|
evilangell
初级用户
 
积分 32
发帖 32
注册 2008-4-18
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
如果是拖一堆东西到批处理图标上的话,只问一次复制到哪儿。
答:根据1,2,3选择对应的目录。
If you drag a bunch of things onto the batch file icon, it will only ask once where to copy them.
Answer: According to 1, 2, 3, select the corresponding directory.
|
|
2010-10-21 22:55 |
|
|
evilangell
初级用户
 
积分 32
发帖 32
注册 2008-4-18
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
有个疑问:
shift /1
什么作用?
最好文件拖到这个批处理图标上后能显示拖进来文件的文件名
There is a question:
What is the function of shift /1?
It is best that after dragging a file to this batch processing icon, the file name of the dragged - in file can be displayed
|
|
2010-10-22 13:58 |
|
|
qinchun36
高级用户
    据说是李先生
积分 609
发帖 400
注册 2008-4-23
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
你不知道拖了多少个到批处理图标上,又要每个都复制,就只好用 shift 去取每个参数了。
关于 shift 的作用你去看看说明或者查查相关帖子,大概就是把后面的参数移位的意思,几句话不好说清楚的。
You don't know how many times you dragged them onto the batch file icon, and then had to copy each one, so you had to use shift to get each parameter.
For the function of shift, you can go to see the instructions or check related posts. It's probably the meaning of shifting the following parameters. A few words can't explain it clearly.
|
|
2010-10-22 16:13 |
|
|
yf6122010
新手上路

积分 18
发帖 18
注册 2010-12-6
状态 离线
|
|
2010-12-9 12:25 |
|
|
yf6122010
新手上路

积分 18
发帖 18
注册 2010-12-6
状态 离线
|
|
2010-12-9 12:25 |
|
|
acaigg
初级用户
 
积分 115
发帖 92
注册 2010-12-24
状态 离线
|
|
2010-12-25 12:20 |
|