![]() |
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-11 17:43 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS批处理 & 脚本技术(批处理室) » 【Solved】Copy only the folder without including its contents |
| Printable Version 3,346 / 19 |
| Floor1 ganjie | Posted 2009-04-05 04:00 |
| 初级用户 Posts 37 Credits 49 | |
|
Little brother wants to copy all folders and subfolders under a certain folder, but not copy the files inside the folders (except for jpg and gif image formats). How to write this? Thank you!
If there are no jpg or gif files in a certain folder? Then do we still need to copy that folder? Yes. [ Last edited by ganjie on 2009-4-6 at 01:21 ] |
|
| Floor2 ZJHJ | Posted 2009-04-05 08:58 |
| 高级用户 Posts 374 Credits 609 | |
| Floor3 czl1378 | Posted 2009-04-05 11:03 |
| 初级用户 Posts 114 Credits 161 | |
|
That makes sense. Why didn't I think of that... First copy all the files and folders. Then delete the files that are not JPG or GIF.
The original poster said: "Don't just give me a Chinese explanation, and don't just give me a short piece of code and let me figure it out by myself. If that's the case, replies are declined"... I'm wondering if I should reply to you. But having a Chinese explanation is better than nothing, right? |
|
| Floor4 Cappuccin0 | Posted 2009-04-05 11:56 |
| 新手上路 Posts 7 Credits 9 | |
|
robocopy Log log2 /mir /zb /xf *.*
Just copy using robocopy while ignoring all files |
|
| Floor5 yishanju | Posted 2009-04-05 11:59 |
| 银牌会员 Posts 1,357 Credits 1,488 | |
|
C:\Documents and Settings\Administrator>xcopy /?
Copies files and directory trees. XCOPY source ] ] ...] source Specifies the file(s) to copy. destination Specifies the location and/or name of new files. /A Copies only files with the archive attribute set, but doesn't change the attribute. /M Copies only files with the archive attribute set, and clears the archive attribute. /D:m-d-y Copies files changed on or after the specified date. If no date is given, copies only those files whose source time is newer than the destination time. /EXCLUDE:file1... Specifies a list of files containing strings. Each string must be in a separate line in the file. If any string matches the full path of the file to be copied, that file will not be copied. For example, specifying a string like \obj\ or .obj will exclude all files under directory obj or files with the .obj extension. /P Prompts for creating each destination file. /S Copies directories and subdirectories except empty ones. /E Copies directories and subdirectories including empty ones. Same as /S /E. Can be used to modify /T. /V Verifies each new file. /W Prompts you to press a key before copying. /C Continues copying even if errors occur. /I If destination does not exist and copying more than one file, assumes that destination is a directory. /Q Does not display file names while copying. /F Displays full source and destination file names while copying. /L Displays files to be copied. /G Allows copying unencrypted files to destinations that do not support encryption. /H Copies hidden and system files also. /R Overwrites read-only files. /T Creates directory structure but does not copy files. Does not include empty directories or subdirectories. /T /E includes empty directories and subdirectories. /U Copies only files that already exist in destination. /K Copies attributes. Normal Xcopy resets read-only attributes. /N Copies using generated short names. /O Copies file ownership and ACL information. /X Copies file auditing settings (implies /O). /Y Copies file auditing settings (implies /O). Existing destination files. /-Y Causes prompting to confirm rewriting an existing destination file. /Z Copies network files in restartable mode. The command-line switch /Y may be preset in the COPYCMD environment variable. This may be overridden with /-Y on the command line. |
|
| Floor6 yishanju | Posted 2009-04-05 11:59 |
| 银牌会员 Posts 1,357 Credits 1,488 | |
|
Try XCOPY /T to create directory structure
|
|
| Floor7 czl1378 | Posted 2009-04-05 14:49 |
| 初级用户 Posts 114 Credits 161 | |
|
People have all said: no Chinese explanations, and no trying to figure it out by himself. Brother yishanju, just post a complete code segment.
|
|
| Floor8 ganjie | Posted 2009-04-05 23:04 |
| 初级用户 Posts 37 Credits 49 | |
|
It's not that I don't want to find a way, but that I'm already trying to find a way. Because the source file is very large, there are hundreds of gigabytes of files. The picture files alone that need to be copied might exceed a gigabyte. Copying all and then deleting, this kind of reply is obviously irresponsible without considering the poster's mood. But I'm grateful for everyone's enthusiastic replies. Thanks! I've already made three batch files by myself, and then used call to call them to achieve the goal. Thanks again!
[ Last edited by ganjie on 2009-4-5 at 23:34 ] |
|
| Floor9 ganjie | Posted 2009-04-06 08:45 |
| 初级用户 Posts 37 Credits 49 | |
|
The complete code of this post is as follows, and it has been tested!
Thanks to Suifeng from the batch processing forum. |
|
| Floor10 dosz | Posted 2009-04-06 09:33 |
| 中级用户 Posts 188 Credits 396 From 上海 | |
|
1, Create the same folder.
2, Copy the image file. Reasonable. |
|
| Floor11 balinger | Posted 2009-04-06 09:43 |
| 中级用户 Posts 115 Credits 356 | |
|
Hey, it's a pity that the original poster's system doesn't have XCOPY!
|
|
| Floor12 dosz | Posted 2009-04-06 10:22 |
| 中级用户 Posts 188 Credits 396 From 上海 | |
Originally posted by balinger at 2009-4-6 09:43: If that's the case, then it's the "copy first and then delete" in the "2nd floor" |
|
| Floor13 netbenton | Posted 2009-04-06 11:47 |
| 银牌会员 Posts 752 Credits 1,916 From 广西 | |
|
The code on the 9th floor, after md, you can immediately copy *.jpg... © *.gif... and omit the subsequent for. It should be more efficient.
|
|
| Floor14 HAT | Posted 2009-04-06 13:03 |
| 版主 Posts 5,017 Credits 9,023 | |
It's not that I don't want to find a way, but that I'm already trying to find a way. Because the source file is very large, there are hundreds of gigabytes of files. The image files alone may exceed a gigabyte. Copying all and then deleting, and then posting back, is obviously an irresponsible reply without considering the mood of the person who posted it. Why didn't you state at the top that the source file is very large? Isn't this a waste of other people's time? You always feel that others' replies are irresponsible, why don't you think about whether your own way of asking questions is responsible? Have you considered the mood of the person who is helping you solve the problem? |
|
| Floor15 HAT | Posted 2009-04-06 13:04 |
| 版主 Posts 5,017 Credits 9,023 | |
Originally posted by balinger at 2009-4-6 09:43 AM: What did you conclude that the owner's system doesn't have XCOPY from? |
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |