Jump to content

How to create BAT that copies everything but excluded things?

RejZoR

I want to make a BAT that would copy all my USERS profile folders from original location to other partition, but I don't want to manually specify what folders I want to copy. Instead I'd like to specify entire LOCAL and ROAMING folders, but only exclude some folders from them. Can this be done? So I'd just run the BAT and it would copy everything in those two folders to destination and exclude Windows stuff that I have no use of and I'm fine if it's left there and lost.

 

Coz, if I make a list of what exactly I want to copy, anything new that is included needs to be included manually. Where exclusion would always gather everything but Windows folders that I know there is no need to copy over. Or few apps whose user profiles are not needed either.

Link to comment
Share on other sites

Link to post
Share on other sites

Copy the entire folders and tell it to then delete the few folders you don't want copied.  It isn't very efficient (especially if the folders you don't want are large), but it will save you writing out all the folders you do want copied.

Grammar and spelling is not indicative of intelligence/knowledge.  Not having the same opinion does not always mean lack of understanding.  

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, mr moose said:

Copy the entire folders and tell it to then delete the few folders you don't want copied.  It isn't very efficient (especially if the folders you don't want are large), but it will save you writing out all the folders you do want copied.

The thing is, I've thought of that, but some folders contain large amounts of small files, there is also TEMP folder that's huge in there and it then takes way longer even on fast SSD. So I want to exclude those from the get go. I'll try IntMD's recommendation and see if it works the way I want it.

Link to comment
Share on other sites

Link to post
Share on other sites

If you don't currently use the Windows File History Backup function. You could configure it to only backup LOCAL and ROAMING and use the Exclude folders list to prevent subfolders you don't want from getting copied. Do it once and turn it off or set it to run at a set interval.

CPU: Vulnerable to Meltdown | Motherboard: Has LEDs that I can't see | RAM: Bought too much | GPU: Mostly satisfactory so far in our relationship | Case: Shiny, black, very heavy and tall, with a Firefox sticker | Storage: Has too many old HDDs | PSU: Hasn't blown up yet like it's predecessor | Displays: Mismatched from Craigslist | Cooling: As many Noctuas as there are fan headers | Keyboard: Keys are fading |  Mouse: Needs cleaning |

Link to comment
Share on other sites

Link to post
Share on other sites

@IntMD

 

Sorry, but I can't figure out that damn thing. I've configured it, even tried bunch of switches for xcopy and it only copies like 1/3 of folders and I havenn't even configured the exclusions yet...

Link to comment
Share on other sites

Link to post
Share on other sites

25 minutes ago, RejZoR said:

The thing is, I've thought of that, but some folders contain large amounts of small files, there is also TEMP folder that's huge in there and it then takes way longer even on fast SSD. So I want to exclude those from the get go. I'll try IntMD's recommendation and see if it works the way I want it.

fair enough,  it was just the first solution I thought up. 

Grammar and spelling is not indicative of intelligence/knowledge.  Not having the same opinion does not always mean lack of understanding.  

Link to comment
Share on other sites

Link to post
Share on other sites

13 minutes ago, mr moose said:

fair enough,  it was just the first solution I thought up. 

I'll actually go that route using my own "framework" coz xcopy just behaves weird. It just doesn't copy everything which is weird. I've made my own tool that just brute copies everything. Takes quite some time, but it's 1 click tool and copies entire folder structure without any fiddling unlike xcopy. Until I figure a proper method...

Link to comment
Share on other sites

Link to post
Share on other sites

What about Robocopy?

https://ss64.com/nt/robocopy.html

use the /XD flag to exclude directory

From same source as @IntMd's Link.

 

Seems very well suited for your backup purposes, since "By default Robocopy will only copy a file if the source and destination have different time stamps or different file sizes."

CPU: Vulnerable to Meltdown | Motherboard: Has LEDs that I can't see | RAM: Bought too much | GPU: Mostly satisfactory so far in our relationship | Case: Shiny, black, very heavy and tall, with a Firefox sticker | Storage: Has too many old HDDs | PSU: Hasn't blown up yet like it's predecessor | Displays: Mismatched from Craigslist | Cooling: As many Noctuas as there are fan headers | Keyboard: Keys are fading |  Mouse: Needs cleaning |

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, Joluch said:

What about Robocopy?

https://ss64.com/nt/robocopy.html

use the /XD flag to exclude directory

From same source as @IntMd's Link.

 

Seems very well suited for your backup purposes, since "By default Robocopy will only copy a file if the source and destination have different time stamps or different file sizes."

I only need to quickly copy user profile when I install Windows clean, the rest is already on second partition. Speeds up Windows install down to like 30 minutes process with everything this way lol

Link to comment
Share on other sites

Link to post
Share on other sites

Use robocopy, then use the /XD param to exclude folders ;

 

robocopy source destination /xd folder1 folder2 folder3

If you need help with your forum account, please use the Forum Support form !

Link to comment
Share on other sites

Link to post
Share on other sites

Oh, Robocopy is part of Windows. I thought it's extra software the entire time... XD

Link to comment
Share on other sites

Link to post
Share on other sites

If only things were ever this simple. The example didn't work, I had to dig through parameters and there was /S missing and using /E kept stalling the damn thing for 30 seconds for no reason because I couldn't understand anything since whole screen was filled with Application Data written trillion times or some shit. And when I used /S parameter it still took RIDICULOUSLY long to copy just a small portion of it. Totally useless.

 

In the end I've made my own tool in 1 minute using installer framework that just brute copies everything from USERS folder to same folder on second partition. And it does the copy of all files in fraction of a time and I even have a nice progress bar to see how far it is. Heh.

Link to comment
Share on other sites

Link to post
Share on other sites

  • 5 months later...
On 8/28/2019 at 11:54 AM, RejZoR said:

If only things were ever this simple. The example didn't work, I had to dig through parameters and there was /S missing and using /E kept stalling the damn thing for 30 seconds for no reason because I couldn't understand anything since whole screen was filled with Application Data written trillion times or some shit. And when I used /S parameter it still took RIDICULOUSLY long to copy just a small portion of it. Totally useless.

 

In the end I've made my own tool in 1 minute using installer framework that just brute copies everything from USERS folder to same folder on second partition. And it does the copy of all files in fraction of a time and I even have a nice progress bar to see how far it is. Heh.

Can u share the script? I am starting to hate robocopy as well.

 

Actually is it possible to write it so it replaces the Notepad file I'm replacing if it realizes that its new and the slave copies are old?

Thanks

Link to comment
Share on other sites

Link to post
Share on other sites

Guest
This topic is now closed to further replies.

×