darellaustin_jr Posted October 5, 2017 Posted October 5, 2017 HI All, I'm very new batch programming and have a question about a task. I'm looking to create a batch programming script where I can copy 10 files at a time every 10 minutes to a destination folder until all files have been copied ex: select 1st 10 files to copy over,wait 10 minutes, then copy next 10 files and so on. This is like a for loop, but confused on how to set it up. I've played around with robocopy cmd but I can only copy all files to a destination folder. ex: I want to copy from this drive: C:\Users\austid02\Desktop\test place files into this folder path: C:\Users\austid02\Desktop\test2 thanks in advance very grateful! Darell 1
jslate1980 Posted October 6, 2017 Posted October 6, 2017 If batch script look at robocopy command if powershell look at copy-item cmdlet. 1
darellaustin_jr Posted October 6, 2017 Author Posted October 6, 2017 Hi there, I know how to do robocopy to copy all files from source to destination, but what I don't know how to do is to set up the syntax of how to select 10 files at a time from a folder every 10 minutes until all files have been copied. I never did batch programming before and i'm learning really on the fly. Any samples of this would be greatly appreciated :-) Thanks
caffrey Posted October 6, 2017 Posted October 6, 2017 (edited) The way I'd do it isn't the most efficient but its late on a Friday and it's how I usually do these things. do a dir /b > filelist.csv which would result in file1.txt file2.txt etc open the filelist.csv in excel, insert columns so you end up with copy file1.txt destination folder e.g. A1, A2, A3 copy, C:\Users\austid02\Desktop\test\file1.txt, c:\C:\Users\austid02\Desktop\test2\ copy, C:\Users\austid02\Desktop\test\file2.txt, C:\Users\austid02\Desktop\test2\ every ten rows add timeout /t 600 /nobreak > NUL save csv edit csv in notepad++ or similar and replace commas with spaces save as a .bat file run batch file in source folder Might work, like I said it's close to beer o clock tho Edited October 6, 2017 by caffrey 2
darellaustin_jr Posted October 6, 2017 Author Posted October 6, 2017 Hey hey, Thanks so much for your time and def understand! This is great and will test this out :-)
caffrey Posted October 6, 2017 Posted October 6, 2017 Only reason I mention Excel, is that it's easy to fill down on the columns for the copy and destination columns if that makes sense 1
darellaustin_jr Posted October 6, 2017 Author Posted October 6, 2017 Hi all, I found a solution and it's posted below! Thanks to everyone @echo offset Source=C:\Users\austid02\Desktop\testset Target=C:\Users\austid02\Desktop\test2set MaxLimit=10for /f "tokens=1* delims=[]" %%G in ('dir /A-D /B "%Source%\*.*" ^| find /v /n ""') do ( copy /y "%Source%\%%~nxH" "%Target%" if %%G==%MaxLimit% exit /b 0) 1
CoolsMK2 Posted January 18, 2018 Posted January 18, 2018 you can do a simple loop with :run copy souce dest ping -n 600 127.0.0.1 >nul goto run miss use of ping but it will work.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now