Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with moving file ranges

Status
Not open for further replies.

loki126

Technical User
May 13, 2005
3
US
I know this may be the wrong forum to post this in, but I really have no idea where else to post. I have a huge project which is quite simple to complete but will be extremely time-consuming. I have over 800,000 files and all files are named in numeric order. I have a list of over 1,000 ranges and I need to place the files corresponding to each range into its own folder which is named the beginning range. To better illustrate:

I have the Ranges-
000001-000009
000010-000013
000014-000015
etc...

Let's take the first range, 000001-000009. I have to create a folder and name the folder "000001". Then I need to place the files from 000001 through 000009 into the folder.

Again, I have over 1,000 of these ranges to do. I was wondering if there is any software or anything out there that completes this project for me?

Thank you VERY much for your help.
 
Too many numbers for me to completely follow what you are trying to do but see if you can make use of a backup program that can restore files to a different folder (location)?
 
Say the text file containing the list of ranges is called myranges.txt. Placing the following as folders.bat in the directory containing myranges.txt as well as the files of interest would yield the folders:

Text of folders.bat
Code:
FOR /F "usebackq tokens=1,2 delims=- " %%i IN (myranges.txt) DO md %%i

Because the filenames are in the form 0000xxxx you run out of .bat capabilities to move the files. Any range processing in a batch file would strip the leading zeroes. If you do not use the first zero as an actual place holder, and changed it to a 1000000 format, then you could easily do the MOVE with a batch file:

Text for the folder_fill.bat file:
Code:
FOR /F "usebackq tokens=1,2 delims=- " %%i IN (myranges.txt) DO (
FOR /L %%T IN (%%i,1,%%j) DO MOVE %%T \%%i)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top