0

I am trying to create a batch file that allows me to transfer files with a FILENAME containing specific numbers. I have thousands of files that have filename in a certain format - with dates at the end (i.e. abc010118.txt) - that I would like to archive.

*Note: the files were created/last modified on the same date, and hence the filename is the only thing that can be used to differentiate one another

Having never studied programming, I searched and tried different things for hours to come up to writing this cmd:

for /f "tokens=*" %a in ('dir C:\Users\abc\Desktop\test\*122718. /ad /b') do robocopy "C:\Users\abc\Desktop\test\%a" "C:\Users\abc\Desktop\dest\%a" /e /v /np /w:1 /r:1 /xo

What I would like to add to my command is to repeat the same action as the one that my command is performing, but with an increment of 100. For example, I would like the files containing the string 010118 at the end to move to another directory and then move files with their name containing the string 010218 to move to another directory and so on.

I would really appreciate any feedback and suggestions on this. Please know that I am completely new to programming and would really appreciate if anyone could give a detailed explanation of each line.

MinJae Kim
  • 19
  • 3
  • 1
    You might find the search phrase `[batch-file] increment number` (with the brackets) useful to help you get started. Use the search box at the top of the page. – Ken White Dec 27 '18 at 17:49
  • Are all the files located in (C:\Users\abc\Desktop\test\\) ..? – John Kens Dec 27 '18 at 18:14
  • 1
    Would be quite tedious to select every number combination. I suggest to use Substrings to extract day,month,year - check if a correspondent folder exits (create if neccessary) and move the file. There **ARE** examples here on [SO] –  Dec 27 '18 at 18:49
  • Possible duplicate of [create batch file based on date in file name and move files](https://stackoverflow.com/questions/50804897/create-batch-file-based-on-date-in-file-name-and-move-files) –  Dec 27 '18 at 18:50
  • All files are located in C:\Users\abc\Desktop\test\, but in different folders within that directory. – MinJae Kim Jan 02 '19 at 23:58
  • I've failed in trying to find in stack overflow to figure out if there's any other post with the same problem. If I am missing something, I would really appreciate directing me to other posts. – MinJae Kim Jan 03 '19 at 00:00
  • Did you solve this issue or do you still need guidance? – John Kens Apr 09 '19 at 20:37
  • Still working on it... – MinJae Kim Apr 11 '19 at 21:20

0 Answers0