Zoom7000 Posted May 26, 2013 Share Posted May 26, 2013 Can someone help me write a quick script to copy files from 1 location to another? I have files in this folder structure: C:\Other Files\Misc\<Load of individual folders with different names>\<Mixture of different file types> I want to copy all the .doc files from the <Mixture of different file types> folder to the following location: E:\Other Files\Misc Can someone help me with a script that will do it for me? Thanks in advance! Link to comment https://www.neowin.net/forum/topic/1154740-script-to-copy-files-of-a-particular-type-from-1-location-to-another/ Share on other sites More sharing options...
helpifIcan Posted May 26, 2013 Share Posted May 26, 2013 Open Notepad Type copy c:\otherfiels\misc\thefolderyouwanttocopyfrom\*.doc(orotherfiletype) e:\otherfiles\misc Save as a mycopyscript.bat You may have to edit the TXT off the end as it may save as mycopyscript.bat.txt Move it to the desktop for easy access Link to comment https://www.neowin.net/forum/topic/1154740-script-to-copy-files-of-a-particular-type-from-1-location-to-another/#findComment-595715182 Share on other sites More sharing options...
Zoom7000 Posted May 26, 2013 Author Share Posted May 26, 2013 On 26/05/2013 at 17:36, helpifIcan said: Open Notepad Type copy c:\otherfiels\misc\thefolderyouwanttocopyfrom\*.doc(orotherfiletype) e:\otherfiles\misc Save as a mycopyscript.bat You may have to edit the TXT off the end as it may save as mycopyscript.bat.txt Move it to the desktop for easy access lol! Give me some credit! That's simple. But I have about 50 odd folders in the Misc folder, I don't want to start typing 50 odd snippets of code in the batch file! It'll probably be faster to do it manually! I wanted to know if it's possible to write a script that will scan the randomly named folders. I.e. What variable do I need to specify for "thefolderyouwanttocopyfrom" part! Link to comment https://www.neowin.net/forum/topic/1154740-script-to-copy-files-of-a-particular-type-from-1-location-to-another/#findComment-595715346 Share on other sites More sharing options...
Max Norris Posted May 26, 2013 Share Posted May 26, 2013 Just dumping them all in one location? Have your script change to the source directory then try something like this: for /r %x in (*.doc) do copy "%x" "D:\Destination\Directory"[/CODE] That'll recursively scan every directory from where its called from. Remember that this'll just dump everything found into one destination, it won't preserve the directory structure. If you want to keep the directory structure, could use RoboCopy instead, included with current versions of Windows, oldies I think need a resource kit. Similar to above, but it'll create directories as needed in the destination instead of just dumping all in one location. Another example: [code]robocopy "C:\Source\Directory" "D:\Destination\Directory" *.doc /s paul0544 and Zoom7000 2 Share Link to comment https://www.neowin.net/forum/topic/1154740-script-to-copy-files-of-a-particular-type-from-1-location-to-another/#findComment-595715378 Share on other sites More sharing options...
Recommended Posts