Question Please help with batch files

Please provide comments and solutions that are helpful to the author of this topic.

Decopi

Level 6
Thread author
Verified
Oct 29, 2017
252
Please, if possible I request help, I need 3 batch files in order to do the following tasks:

BATCH01
Go to drive X1:\ => Delete everything (folder, subfolders and files) exept folders "X1:\System Volume Information" and "X1:\$RECYCLE.BIN"
Go to drive X2:\ => Copy everything (folder, subfolders and files) exept folders "X2:\System Volume Information" and "X2:\$RECYCLE.BIN" => Go to drive X1:\ => Paste everything (folder, subfolders and files)

BATCH02
Go to drive X3:\ => Go to folder X3:\Y3 => Delete everything (folder, subfolders and files)
Go to drive X4:\ => Go to folder X4:\Y4 => Copy everything (folder, subfolders and files) => Go to folder X3:\Y3 => Paste everything (folder, subfolders and files)

BATCH03
Go to drive X5:\ => Delete everything (folder, subfolders and files) exept folders "X5:\System Volume Information", "X5:\$RECYCLE.BIN" and "X5:\Whatever"
Go to drive X6:\ => Copy everything (folder, subfolders and files) exept folders "X6:\System Volume Information", "X6:\$RECYCLE.BIN" and "X6:\WhateverAgain" => Go to drive X5:\ => Paste everything (folder, subfolders and files)

Thank you in advance
 
  • Like
Reactions: Trident

MuzzMelbourne

Level 15
Verified
Top Poster
Well-known
Mar 13, 2022
599
Why do you need batch files?

Why not just substitute human speak for computer speak and do it from the CL?

...or is this just a sneaky way of completing a school assignment...?🫣
 
  • Like
Reactions: Trident

Decopi

Level 6
Thread author
Verified
Oct 29, 2017
252
Why do you need batch files?
For specific repeatably tasks that will be needed at specific moments of the week.
Why not just substitute human speak for computer speak and do it from the CL?

...or is this just a sneaky way of completing a school assignment...?🫣
It's not sneaky, nor school assignment. It's a simple request for help with batch files. That's all.
 

Decopi

Level 6
Thread author
Verified
Oct 29, 2017
252
I had a great help in other forum. I almost solved 99% of my needs. I share with you here, in case is useful to someone:

This batch will format F: (more efficient and fast than command delete). Then it will copy everything inside E: (except Folder One and Folder Two) to F:
@echo off
Format F: /FS:NTFS /V:NAME /Q /X /y
robocopy.exe E:\ F:\ *.* /mir /XD "Folder One" "Folder Two" /copy:DAT /dcopy:DA /r:0 /v /xj /mt:32

And this batch will copy everything inside I: (except Folder One and Folder Two) and then it will copy to J:
This batch is amazing because only pastes (at J:) new or changed files.
@%SystemRoot%\System32\robocopy.exe I:\ J:\ /E /MIR /MT:32 /NDL /NFL /NJH /NJS /R:0 /XJ /XD "I:\Folder One" "I:\Folder Two"

Another different version:
@echo off
md J:\empty
robocopy /mir J:\empty J:\ /xd "Folder One" "Folder Two"
robocopy.exe I:\ J:\ *.* /mir /XD "Folder One" "Folder Two" /copy:DAT /dcopy:DA /r:0 /v /xj /mt:32

All batches are tested and working like a charm.
Hope it'll help.
 

Decopi

Level 6
Thread author
Verified
Oct 29, 2017
252
Was ChatGPT unable to compile these, or you just don’t like it?

I do like ChatGPT, and it has helped me a lot in several different subjects.
But, when I try ChatGPT for computer programming, or for CMD commands and similar... ChatGPT is full of wrong stuff. Honestly, that's my personal opinion, and I lost patience with ChatGPT on specific subjects. I'll say is a great tool, but for me it's not the answer for everything... at least, not yet :ROFLMAO:
 
  • Like
Reactions: Trident

Decopi

Level 6
Thread author
Verified
Oct 29, 2017
252
Also, are you looking to format flash drives or something?

Backup software (even Windows one in Control Panel) are not customizable enough for my needs.
So I built specific batches for specific partitions in order to keep some backups, images and clone partitions.
 
  • Like
Reactions: Trident

quentisa

Level 1
Jan 6, 2023
11
Please, if possible I request help, I need 3 batch files in order to do the following tasks:

BATCH01
Go to drive X1:\ => Delete everything (folder, subfolders and files) exept folders "X1:\System Volume Information" and "X1:\$RECYCLE.BIN"
Go to drive X2:\ => Copy everything (folder, subfolders and files) exept folders "X2:\System Volume Information" and "X2:\$RECYCLE.BIN" => Go to drive X1:\ => Paste everything (folder, subfolders and files)

BATCH02
Go to drive X3:\ => Go to folder X3:\Y3 => Delete everything (folder, subfolders and files)
Go to drive X4:\ => Go to folder X4:\Y4 => Copy everything (folder, subfolders and files) => Go to folder X3:\Y3 => Paste everything (folder, subfolders and files)

BATCH03
Go to drive X5:\ => Delete everything (folder, subfolders and files) exept folders "X5:\System Volume Information", "X5:\$RECYCLE.BIN" and "X5:\Whatever"
Go to drive X6:\ => Copy everything (folder, subfolders and files) exept folders "X6:\System Volume Information", "X6:\$RECYCLE.BIN" and "X6:\WhateverAgain" => Go to drive X5:\ => Paste everything (folder, subfolders and files)

Thank you in advance
here you go:

Code:
@echo off
rem Deleting everything in X1 except System Volume Information and $RECYCLE.BIN
cd /d X1:\
rmdir /s /q "X1:\Folder1"
rmdir /s /q "X1:\Folder2"
rem Copying everything from X2 to X1
cd /d X2:\
xcopy /s /e /exclude:X2:\exclude.txt X1:\
 
  • Thanks
Reactions: Decopi

About us

  • MalwareTips is a community-driven platform providing the latest information and resources on malware and cyber threats. Our team of experienced professionals and passionate volunteers work to keep the internet safe and secure. We provide accurate, up-to-date information and strive to build a strong and supportive community dedicated to cybersecurity.

User Menu

Follow us

Follow us on Facebook or Twitter to know first about the latest cybersecurity incidents and malware threats.

Top