Batch command for copying files | Batch File for Copying Files from one Location to Another

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys in this video we are going to learn how will you copy the files and the names of the files are written inside a text document reading that text document you have to capture the file names and based on the names you have to move those files from The Source folder to the destination folder this would be amazing so let's move on to our screen and let's see how this can be done hey guys so let's see how this can be achieved the very first thing we will do we will create some three text documents we will name it as test one the first one and I'm creating inside a test folder okay documents test folder and inside that I'm creating some test files okay just to experiment the specific requirement and I'm going to name it as test 3. all right so now inside the documents I have created a test folder and there are three files inside this now I will move to the batch script folder where my scripts have kept in this folder I am going to create a simple text document okay and here I am going to name it as my text Dot dot txt okay so it's a my text and inside this one all the three test files we have created inside that we are going to write it okay inside this we are going to write it so I'm going to name first test1.txt 2 Dot txt and then test 3 dot txt so how many files we have got three files inside of my text document so what is the job here let me save it so the job here is that this specific text document right this specific text document has got three names we have to design a basket in such a way that it will go as per the names that are there so let me create one more called test 4 here so that's it should not move okay so for example test four so this test for name is not available in this document so it should only move this one two three not the four so how this can be achieved in the basket let's see that okay it's quite easy but it appears slightly complicated but it is not so let's see how this can be achieved let's move on to our basket and start writing so in this one our basket this specific document my text document the first we have to read this document right now to read this document I will move on to the specific directory and say CD this one so that it gets into that and then I will use a for each Loop okay 4 slash F and then I need to read it so what I will use I will use delims so in the previous video I spoke about tokens and delims so you must have got a clarity as to what is a token what is a dilem and here what I'm going to say equals to so when I say equals to that means in this text document right in this text document there is no comma node delimiter so by default it will say if there is a space after that it is going to read each line so it will pick first second and third okay I'll show you how how that is working and then I'm going to say percentage percentage G after space percentage person is G in the file name what is the file name the file name is my text my text Dot txt then I will say do so what is that how this is working let me first show you so that you will have a better idea as to what is this written for now if I say Echo and I will say percentage percentage G what would happen let me show you this is going to read this mytext.txt and because I have written no delimiter here delims equals to equals to when I write what would happen it is going to just pick because there is no comma there is nothing right so it is go to each line and pick the whatever is written here okay this what we are designing will work only when the inputs are given in this format okay remember that this is completely for a learning purpose I'm doing now you got an understanding of delims equals to so we are not mentioning any delimiter like comma or a space or nothing we are mentioning simply we are writing so that it will pick everything that is there inside this one by one on from each line all right so let's see this is the output let's see how the output is coming so that you will get a better idea so you can see the output what it did it first picked test1.txt then pick Test 2 then pick test 3. so now from the script this is clear that what this one is doing okay we anyways we don't need this I'm going to delete it I have to copy the main aim is to copy the files listed in a text file so from the text file we got the names now we have to copy so I'll use a copy command then I have to provide the source destination now if you see The Source destination is different this is the source destination right so I'll copy this and within double code if your destination let's say something has a space test space one something like that is there then you have to use a double quote otherwise not required but if you put a double quote it doesn't harm you and then here inside that what is containing the file name percentage percentage G so I am going to Simply write percentage percentage mg done now where you would like to copy the destination folder is my backup folder inside document that is in the folder I have created called backup and in into this it should transfer the files or copy the files clear now let me save it and let's run the script now if you see what did it say one file copied one file copied one file copied press any key to continue okay so that means the job is done now let's go back to the backup folder and you can see only test one test two test three got copied let's make bit of modification I will not keep test two okay instead I'll keep something called test four let's say dot pxt and save it let's clear the backup folder let me delete let me clear it let's run the script once again if I run the script you can see all the three things got copied let's go to the backup folder now you can see test one test three test four got copied not the test so based on our input it is copying the files from The Source folder to a destination folder I hope this would have added a lot into your knowledge Bank ensure you subscribe to our Channel and continue to learn every day I'm trying to uh publish one video at least so please do continue to watch spend little time to go through each of the video so that you stay up to date and keep revising those videos whenever you have a free time thank you guys for watching let's move on to our next topic
Info
Channel: Automate with Rakesh
Views: 15,899
Rating: undefined out of 5
Keywords: batch file, batch scripting, batch file command, batch file tutorial, batch file for copying files, batch file for copying files over network, batch file for copying files from one location to another, batch command copy and rename file, batch command for copying files, batch script to copy specific files from one folder to another, batch file to copy files from a text list, copy files listed in a text file, batch copy file, copy file cmd, copy, file, cmd, batch, for /f
Id: U8ahxSRUnDs
Channel Id: undefined
Length: 7min 16sec (436 seconds)
Published: Tue Dec 27 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.