Computing.Net > Forums > Programming > batch file rename and move director

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

batch file rename and move director

Reply to Message Icon

Original Message
Name: jimmy6154
Date: June 5, 2007 at 17:38:55 Pacific
Subject: batch file rename and move director
OS: winXP
CPU/Ram: 1gig
Model/Manufacturer: IBM M55
Comment:

hello,

I know that is kind of a mouth full but let me see if I can draw it out to give the format a visual

so the root
c:\ftp\

which has 3 folders in it
c:\ftp\main\
c:\ftp archive\
c:\ftp\new\

so say in c:\ftp\main\
there are 3 folders named
c:\ftp\main\1\
c:\ftp\main\2\
c:\ftp\main\3\

and in the c:\ftp\archive folder there is the 6 folders
c:\ftp\archive\1\
c:\ftp\archive\2\
c:\ftp\archive\3\
c:\ftp\archive\4\
c:\ftp\archive\5\
c:\ftp\archive\6\

and in the c:\ftp\new folder there is 2
c:\ftp\new\1\
c:\ftp\new\2\

What I would like to do is take the 1 folder in the new directory and place it in the main folder. But not overwrite the 1 directory in the main folder instead change the 1 to a 2 and 2 to a 3 and 3 to a 4 etc.
Then the last directory in c:\ftp\main\ which is folder 5 will be moved to the archive folder and added to the list as 7 or what ever the next number in line is.

its basicly a chain of events that takes a folder from new, buts it as the #1 folder in the main and pushes the main's folders down a step. When a folder in the main reaches the last step its added to the archive folder.

I know that is a ton but I hope someone can help. thanks again in advance


Report Offensive Message For Removal


Response Number 1
Name: jimmy6154
Date: June 5, 2007 at 18:09:10 Pacific
Reply: (edit)

sorry, also wanted to add that each folder has files in them and the files have to move with their corisponding folders. Also just to clerify I want to always take the #1 folder from the new directory. The new folder is where I plan on adding new stuff, then when I run this script, the added folders are added to the main.

thanks again


Report Offensive Follow Up For Removal

Response Number 2
Name: Razor2.3
Date: June 6, 2007 at 21:32:31 Pacific
Reply: (edit)

I suppose I could give you a .CMD (.BAT) file that does what you want, but I won't, because I'm apparently the VBScript pusher on this site.

Oh, this might not be the easiest/cleanest way to do it, but the script won't break if there are ever more than 5 subfolders in new.


With CreateObject("Scripting.FileSystemObject")
Set dMain = .GetFolder("C:\ftp\main")
Set dArch = .GetFolder("C:\ftp\archive")
Set dNew = .GetFolder("C:\ftp\new")

For Each i In dNew.SubFolders
dMain.SubFolders("5").Move dArch.Path & "\" & dArch.SubFolders.Count + 1
For j = 4 To 1 Step -1
dMain.SubFolders(CStr(j)).Name = j + 1
Next
i.Move dMain.Path & "\1"
Next
End With

'You know, one of these days, I'll make some program that'll insert the same highlighting into these posts that I see when I use Notepad++.

Edit: VBScript should be saved with a .vbs.


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home








Do you own an iPhone?

Yes
No, but soon
No


View Results

Poll Finishes In 7 Days.
Discuss in The Lounge
Poll History




Data Recovery Software