Need help making a loop in a .cmd file

  • Thread starter Thread starter emanuel.levy
  • Start date Start date
E

emanuel.levy

I need to copy a few thousand files from one directory into sub
directories. They are named in the format

aabbbb-cc-ddddd.zip

I have to following script which when run specifying the last two
digits of bb mopves the files into the right folder. The problem is I
have over 10000 files going from 2206 on up.

I'l like to have it loop after it moves all aabbbb's and add 1 to the
bbbb so it continues to cycle untle the original folder is empty

Here is my current code

mkdir cd22%1
cd cd22%1
dir ..\..\cd22%1-*.*
move ..\..\cd22%1-*.* .
cd ..

I run it by typing doit and the last 2 numbers I want
 
I need to copy a few thousand files from one directory into sub
directories. They are named in the format

aabbbb-cc-ddddd.zip

I have to following script which when run specifying the last two
digits of bb mopves the files into the right folder. The problem is I
have over 10000 files going from 2206 on up.

I'l like to have it loop after it moves all aabbbb's and add 1 to the
bbbb so it continues to cycle untle the original folder is empty

Here is my current code

mkdir cd22%1
cd cd22%1
dir ..\..\cd22%1-*.*
move ..\..\cd22%1-*.* .
cd ..

I run it by typing doit and the last 2 numbers I want

I read your question about six times and I think I was able to
work out what you want to do:
- You have a large number of files called aa??yy-cc-ddddd.zip.
- You wish to create a number of folders called cd22yy.
- You then wish to move all files called aa??yy-cc-ddddd.zip
into the appropriate folders, hence
aa??33-cc-ddddd.zip goes into cd2233,
aa??64-cc-ddddd.zip goes into cd2264 etc.
- The numbers ?? and yy are always two digits and they
never use a leading 0.

I can show you how it's done but before I make the effort
I need your confirmation that my assumptions are correct.
If they are not then you need to spend the time to list some
specific examples.
 
Back
Top