![]() |
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-08-27 07:18 |
47,812 topics / 349,912 posts / today 2 new / 48,264 members |
| 其它操作系统综合讨论区 » [fixed] How to use a command to specify the path of identically named files under different usernames? |
| Printable Version 1,225 / 9 |
| Floor1 superadam | Posted 2007-08-20 10:42 |
| 初级用户 Posts 51 Credits 113 | |
| Floor2 akin520 | Posted 2007-08-20 11:32 |
| 初级用户 Posts 30 Credits 71 | |
| Floor3 Climbing | Posted 2007-08-20 14:32 |
| 铂金会员 Posts 2,753 Credits 6,962 From 河北保定 | |
|
Use the for command to extract the output of the following command:
dir "c:\Documents and Settings" /b /d |
|
| Floor4 superadam | Posted 2007-08-20 16:03 |
| 初级用户 Posts 51 Credits 113 | |
|
Thanks, using dir "c:\Documents and Settings" /b /d I can already get the usernames, but how do I use the for command to extract the output of the following command? I tried several times and still couldn't do it. Climbing and all experts, please help again, many thanks!
[ Last edited by superadam on 2007-8-20 at 04:05 PM ] |
|
| Floor5 itolaiai | Posted 2007-08-20 17:43 |
| 初级用户 Posts 11 Credits 25 | |
|
Just passing by`
[ Last edited by itolaiai on 2007-8-21 at 05:05 PM ] |
|
| Floor6 Climbing | Posted 2007-08-21 08:19 |
| 铂金会员 Posts 2,753 Credits 6,962 From 河北保定 | |
|
Basically as the poster above wrote, you can also do it like this:
for /f "usebackq delims=" %i in (`dir /b/d "c:\documents and settings"`) do xcopy /e/i "c:\documents and settings\%i\Favorites" "x:\target" x:\target means the target directory. |
|
| Floor7 superadam | Posted 2007-08-21 08:50 |
| 初级用户 Posts 51 Credits 113 | |
Originally posted by Climbing at 2007-8-21 08:19 AM: The answer I'm adopting now is as follows: for /f "usebackq delims=" %i in (`dir /b/d "c:\documents and settings"`) do xcopy /e/i "c:\documents and settings\%i\Favorites" "x:\target" Many thanks to the two posters above for the replies. After using Climbin's method, the problem has been completely solved. But I still have one more question now. May I continue to ask Climbin something? What's the difference in syntax between "usebackq delims=" and "delims="? How should it be explained? [ Last edited by superadam on 2007-8-21 at 09:31 AM ] |
|
| Floor8 Climbing | Posted 2007-08-21 09:31 |
| 铂金会员 Posts 2,753 Credits 6,962 From 河北保定 | |
|
This is how I understand usebackq: use backquotes (`) to enclose the command sequence that will be executed. Under normal circumstances, single quotes (') are used to enclose the command, but sometimes the command arguments need single quotes or double quotes as well (and then it causes confusion between single and double quotes). In that case it's best to use the usebackq parameter, and then use backquotes to enclose the command, so this kind of trouble won't happen.
As for the "delims=" parameter, it is used to specify the string delimiter. The for /f command is mainly used to extract fields from a string. Since there is a distinction between fields, there must be symbols to separate the fields. By default it is space or Tab. You can use delims= to specify the delimiter you want to use, and in this example, of course you do not want to use any delimiter, so delims= is specified as empty. For this, you can just check Microsoft's for /?. Although its explanation feels rather confusing, after enough time you'll naturally understand it. |
|
| Floor9 yjd | Posted 2007-08-21 09:32 |
| 初级用户 Posts 76 Credits 156 | |
|
Run cmd and enter for /? and you should see something.
|
|
| Floor10 superadam | Posted 2007-08-21 09:33 |
| 初级用户 Posts 51 Credits 113 | |
|
Alright, I'll look at the syntax first. If there's anything I don't understand, I'll ask you again~~
Thanks, Climbing, for taking your valuable time to reply. Your reply was really timely, thanks. The problem has been successfully solved. Really, really many thanks! This thread can be closed now. Please have a moderator close it for me, thanks~~:D [ Last edited by superadam on 2007-8-21 at 09:35 AM ] |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |