clickcas.blogg.se

Batch file copy files from subfolders to another location
Batch file copy files from subfolders to another location













batch file copy files from subfolders to another location batch file copy files from subfolders to another location

So it sounds like you want to copy only those files whose names are in the given file list. However, if you’re using Windows NT 4.0, just delete the /y switch altogether – it’s only supported in Windows XP and Windows 2000. To turn this off (have it prompt you), change /y to /y- in the batch file. Note: The batch file overwrites files in the destination automatically. Another trick in here is the output parser pipe, which allows us to automatically press the “D” key with each xcopy command. Then run the batch file and viola! You’ve got to love the for command, which lets you (among other things) parse text files and use the line-by-line output. Put the file list in the same directory as the batch file and name the file list filelist.txt. (I used c:\temp\ for testing.) Change \\server\share\folder to the root folder of the files to copy.įor /f "delims=" %%i in (filelist.txt) do echo D|xcopy "\\server\share\folder\%%i" "c:\temp\%%i" /i /z /y

batch file copy files from subfolders to another location

Change c:\temp\ to whatever path you want the files copied to. We’ll call the batch file xcopylist.bat its one line of content is below. The solution to this is to make a simple batch file that parses the content of the text file, generating the appropriate xcopy command to copy the file.

batch file copy files from subfolders to another location

A simple file copy won’t work because there may be files in the source folders which should not be copied.Ĭlient\CD120\Samarai Legends\Drafts\drafts folder.txtĬlient\CD120\Samarai Legends\Inbox\Legends.docĬlient\CD120\Bushido Warriors\Inbox\Warrior Code.doc Given a text file which provides a list of files, copy the files from a fixed source to a fixed destination, recreating the directory trees on the destination. In a nutshell, here is the high-level description of what the script must do: The path in the new location should begin with the part after “folder”… All are currently located in \\server\share\folder. … would want to copy all files on this list to another location (doesn’t really matter where for now).















Batch file copy files from subfolders to another location