|
echo
初级用户
 
积分 148
发帖 69
注册 2006-11-23
状态 离线
|
『楼 主』:
怎样从外部获得多个变量来支持多文件?已解决
使用 LLM 解释/回答一下
@echo off
if not exist "f:\备份" md "f:\备份"
:start
if not "%~1"=="" (
move "%~1" f:\备份\
shift
goto :start)
pause>nul
引用2楼兄台的代码,测试过,支持拖放操作,已经很好地解决了我前面提出的问题:(目前只能支持单文件,而且文件名不能有空格,不知道如何改进才能支持多文件(多于9个),而且不受空格的影响,我把%1改成"%1"提示说命令语法不支持。),但测试后发现不支持文件夹,不知道该怎么样完善下?
可能我前面没说清楚,不好意思,其实我是想把这个P放到SENDTO里头来用,或者直接将多个文件拖放到这个P上来操作
大虾门帮忙看看。。。:lol:
Last edited by echo on 2006-12-12 at 04:50 PM ]
@echo off
if not exist "f:\Backup" md "f:\Backup"
:start
if not "%~1"=="" (
move "%~1" f:\Backup\
shift
goto :start)
pause>nul
Quoting the code from the second-floor brother, I tested it and it supports drag-and-drop operations, which has well solved the problem I mentioned earlier: (Currently it can only support single files, and the file name cannot have spaces. I don't know how to improve it to support multiple files (more than 9) and not be affected by spaces. I changed %1 to "%1" and it prompted that the command syntax is not supported.) However, after testing, it is found that it does not support folders. I don't know how to improve it?
Maybe I didn't make it clear earlier, sorry. Actually, I want to put this P into SENDTO to use, or directly drag and drop multiple files onto this P to operate
Great gods, please take a look... :lol:
Last edited by echo on 2006-12-12 at 04:50 PM ]
|
|
2006-12-12 01:42 |
|
|
youxi01
高级用户
   
积分 846
发帖 247
注册 2006-10-27 来自 湖南==》广东
状态 离线
|
|
2006-12-12 05:48 |
|
|
NaturalJ0
银牌会员
    
积分 1181
发帖 533
注册 2006-8-14
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
输入时你加上引号,传进去后去掉再用,如果要超过 9 个,应该要用 shift 。
When inputting, you add quotes, pass them in and then remove them. If it exceeds 9, you should use shift.
|
|
2006-12-12 06:05 |
|
|
youxi01
高级用户
   
积分 846
发帖 247
注册 2006-10-27 来自 湖南==》广东
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
TO :楼上,楼主出现的问题主要不是引号的问题,而是空格的问题,应该!
TO: upstairs, the main problem the original poster has is not the issue of quotation marks, but the issue of spaces, should!
|
|
2006-12-12 06:29 |
|
|
3742668
荣誉版主
      
积分 2013
发帖 718
注册 2006-2-18
状态 离线
|
|
2006-12-12 10:29 |
|
|
youxi01
高级用户
   
积分 846
发帖 247
注册 2006-10-27 来自 湖南==》广东
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
斑竹的代码真是极尽简洁之能啊!羡慕!!!
The code of the moderator is really extremely concise! Envious!!!
|
|
2006-12-12 10:57 |
|
|
sea2moon
初级用户
 
积分 47
发帖 23
注册 2006-9-27
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
请问
@echo off
md D:\备份 2>nul
for %%i in (%*) do move …………
中的,
%* 相不相当于 *.* ?
Does %* in the line @echo off
md D:\备份 2>nul
for %%i in (%*) do move …………
equivalent to *.*?
|
|
2006-12-12 11:11 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
%* 表示 call 语句所引用的所有参数,和 *.* 完全不一样。
%* means all parameters referenced by the call statement, which is completely different from *.*.
此帖被 +2 点积分 点击查看详情 评分人:【 echo 】 | 分数: +2 | 时间:2006-12-12 23:53 |
|
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-12-12 11:15 |
|
|
3742668
荣誉版主
      
积分 2013
发帖 718
注册 2006-2-18
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
Originally posted by youxi01 at 2006-12-12 10:57:
斑竹的代码真是极尽简洁之能啊!羡慕!!!
要想代码好,if尽量少;要想代码壮,引号括号两边放。<img src="images/smilies/face-laugh.png" align="absmiddle" border="0">
你也不用妄自菲薄,你的代码也是本论坛中比较有创造性的之一。
Originally posted by youxi01 at 2006-12-12 10:57:
The moderator's code is really extremely concise! Envious!!!
To write good code, use as few ifs as possible; to make code robust, put quotes and parentheses around both sides. :)
You don't need to belittle yourself either, your code is also one of the more creative ones in this forum.
|
|
2006-12-12 11:47 |
|
|
echo
初级用户
 
积分 148
发帖 69
注册 2006-11-23
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
谢谢各位,学习了,我上面可能没说清楚
我是想它支持拖放操作,即将多个文件直接拖到这个P上进行处理,或者把这个P放到SENDTO里,这样比较省心!
上面没说清楚,不好意思,谢谢大家
Last edited by echo on 2006-12-12 at 11:13 AM ]
Thanks everyone, I've learned. Maybe I didn't make it clear above.
I want it to support drag-and-drop operations, that is, directly drag multiple files to this P for processing, or put this P into SENDTO, which is more worry-free!
I didn't make it clear above, sorry, thank you all
Last edited by echo on 2006-12-12 at 11:13 AM ]
|
|
2006-12-12 23:35 |
|
|
echo
初级用户
 
积分 148
发帖 69
注册 2006-11-23
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
Originally posted by youxi01 at 2006-12-11 04:48 PM:
试试以下的代码,支持多个文件,支持拖放,但是对于具有重复名的文件,在移动过程中进行覆盖且不提示!!!有需要的话自己改进!!!
@ ...
你明白了我的意思,呵呵,代码我测试过
支持拖放操作,支持空格文件名和多于九个文件,太棒了!!!
谢谢你,谢谢大家!
Last edited by echo on 2006-12-12 at 11:13 AM ]
Originally posted by youxi01 at 2006-12-11 04:48 PM:
Try the following code, which supports multiple files and drag-and-drop. However, for files with duplicate names, it overwrites them during the move without prompting!!! Improve it yourself if needed!
@ ...
You understand what I mean, hehe. I tested the code.
Supports drag-and-drop operations, supports files with spaces in their names and more than nine files. Great!!!
Thank you, thank you everyone!
Last edited by echo on 2006-12-12 at 11:13 AM ]
|
|
2006-12-12 23:40 |
|
|
kcdsw
中级用户
  
积分 404
发帖 179
注册 2006-3-30
状态 离线
|
 『第 12 楼』:
使用 LLM 解释/回答一下
用了至少半年了,你自己改改.
还没见到不支持的文件或者文件夹
参数不限!(超过9个文件 or 文件夹 or 文件+文件夹)
我把这个批处理做了个快捷方式(可以最小化运行)
一个放在桌面 一个放在sendto
相当的节省时间!
@echo off
REM 分析当天日期
For /F "tokens=1" %%a in ('date/t') do set Day=F:\print\%%a
REM 如果不存在%day% 则创建!
if not exist %day% Md %day%
:o
REM 如果没有参数则打开%day%文件夹,并且退出程序(如双击,用来查看里面都有些什么文件了!)
if == start explorer %DAY% & exit
REM 检查这个路径是文件,还是文件夹
dir %1\. >nul 2>nul && goto Folder
REM 如果是文件,则执行以下命令
echo.
echo 正在移动%~1,请稍候!
title 移动"%~nx1"中,请稍候!
move %1 %day%
:shift
REM 检测当前参数的下一个参数是否为空,是则跳出程序!
If %2#==# exit
Shift
goto o
:Folder
REM 如果是文件夹,执行以下命令
set Folder="%day%\%~nx1"
md %Folder% && xcopy /y /s /i %1 %Folder% && rd /s /q %1
goto shift
Last edited by kcdsw on 2006-12-13 at 03:43 AM ]
I've been using it for at least half a year, you can modify it yourself.
Haven't seen any un supported files or folders yet
Parameters are unlimited! (More than 9 files or folders or files + folders)
I made a shortcut for this batch file (can run minimized)
One is placed on the desktop and one is placed in sendto
Quite time-saving!
@echo off
REM Analyze the current date
For /F "tokens=1" %%a in ('date/t') do set Day=F:\print\%%a
REM If %day% does not exist, then create it!
if not exist %day% Md %day%
:o
REM If there are no parameters, open the %day% folder and exit the program (such as double-clicking, used to see what files are inside!)
if == start explorer %DAY% & exit
REM Check whether this path is a file or a folder
dir %1\. >nul 2>nul && goto Folder
REM If it is a file, execute the following command
echo.
echo Moving %~1, please wait!
title Moving "%~nx1", please wait!
move %1 %day%
:shift
REM Check whether the next parameter of the current parameter is empty, if it is, jump out of the program!
If %2#==# exit
Shift
goto o
:Folder
REM If it is a folder, execute the following command
set Folder="%day%\%~nx1"
md %Folder% && xcopy /y /s /i %1 %Folder% && rd /s /q %1
goto shift
Last edited by kcdsw on 2006-12-13 at 03:43 AM ]
此帖被 +7 点积分 点击查看详情 评分人:【 redtek 】 | 分数: +5 | 时间:2006-12-13 04:42 | 评分人:【 echo 】 | 分数: +2 | 时间:2006-12-14 01:52 |
|
|
|
2006-12-13 03:23 |
|
|
echo
初级用户
 
积分 148
发帖 69
注册 2006-11-23
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
先顶再看,看起来正合我意,谢谢
我顶!
确实不错,今天不能给你评分了,限制了,明天吧,以后有好东西多拿出来共享哦!
Last edited by echo on 2006-12-12 at 03:38 PM ]
First, top it and then read. It seems just what I want, thank you.
I top!
It's really good. I can't rate you today, it's restricted. Tomorrow. In the future, if there are good things, bring them out and share more!
Last edited by echo on 2006-12-12 at 03:38 PM ]
|
|
2006-12-13 04:34 |
|
|
kcdsw
中级用户
  
积分 404
发帖 179
注册 2006-3-30
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
呵呵 我这个程序是每天工作都用的
目的就是为了把要处理的文件放到 以当日日期为名的文件夹中 以保证服务器能从这里取到文件.(因为,如果都放在一个目录里,容易出现重名,或者文件过多,服务器响应慢)
然后需要支持所有可能性(文件已打开除外)
1.右键sendto
2.拖放
3.方便查看
4.支持文件夹
5.移除原文件
另外 为了方便我操作.我在其快捷方式中设置了快捷键.一按立刻就打开了当天的文件夹.
我觉得完全是利用了系统的很多其他功能 才使得这个批处理用起来感觉是那么那么的好
比如:sendto , 快捷键 , 最小化运行 等等等等
所以我觉得这个东西其实很适合你拿回去做备份
这个日期为名的文件夹形式可以保留一下
只需要改动目标文件夹.
Last edited by kcdsw on 2006-12-13 at 04:45 AM ]
Hehe, this program is what I use every day for work.
The purpose is to put the files to be processed into a folder named after the current date, so that the server can get the files from here. (Because if all are placed in one directory, it's easy to have duplicate names or too many files, and the server response is slow.)
Then it needs to support all possibilities (except when the file is open)
1. Right-click sendto
2. Drag and drop
3. Easy to view
4. Support folders
5. Remove the original file
In addition, for my convenience in operation, I set a shortcut key in its shortcut, and I can open the folder of the current day immediately with one press.
I think it's completely using many other functions of the system, which makes this batch processing feel so, so good
For example: sendto, shortcut key, running in minimized form, and so on and so forth
So I think this thing is actually very suitable for you to take back for backup
This folder form named after the date can be retained.
Only the target folder needs to be changed.
Last edited by kcdsw on 2006-12-13 at 04:45 AM ]
此帖被 +2 点积分 点击查看详情 评分人:【 echo 】 | 分数: +2 | 时间:2006-12-14 01:53 |
|
|
|
2006-12-13 04:42 |
|
|
echo
初级用户
 
积分 148
发帖 69
注册 2006-11-23
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
Originally posted by kcdsw at 2006-12-12 03:42 PM:
呵呵 我这个程序是每天工作都用的
目的就是为了把要处理的文件放到 以当日日期为名的文件夹中 以保证服务器能从这里取到文件.(因为,如果都放 ...
刚刚测试过,真是太爽了,哈哈,我就不说了。。。
看来大家都各自藏着些好宝贝哦!
学习、受教、受用了,谢谢!:P
Last edited by echo on 2006-12-12 at 03:53 PM ]
Originally posted by kcdsw at 2006-12-12 03:42 PM:
Hehe, this program of mine is used every day at work.
The purpose is to put the files to be processed into a folder named after the current date, so that the server can get the files from here. (Because, if all are placed...
Just tested it, it's really great, haha, I won't say more...
It seems that everyone has some good treasures hidden!
Learned, instructed, and benefited, thank you! :P
Last edited by echo on 2006-12-12 at 03:53 PM ]
|
|
2006-12-13 04:48 |
|