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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving folders/directories using a *.bat batch script file...

Status
Not open for further replies.

OMJ

Technical User
May 7, 2008
9
GB
I'm unsure if this is the right forum so please let me know where to post this if this is the wrong place.

My problem is this:

I have about 2500+ folders located in a directory "C:\Projects", in a folder structure of "C:\Projects\0", "C:\Projects\100", "C:\Projects\200" and so on up to "C:\Projects\2500". Inside each folder (say the "500" folder) there is one folder per project number; so for e.g. "C:\Projects\500\500" and up to "C:\Projects\500\599" for each one.

I have a list in an Excel spreadsheet of about 1700 folders which I want to move to another directory "C:\SeparatedProjects", but retaining the same directory structure they previously had.

Is it possible to write a batch script file to move only the folders listed in the Excel spreadsheet? I'm not too sure about this...

Please let me know if this makes any sense, too!
 
Yes it is possible. Sort of. You would need to save the excel file as a CSV. Then you could have the batch read it and do the copying.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
I've made some progress with this, in terms of automating the process which works out which folders are needing to be moved and which don't (not written in a batch script).

I'm now at a point where I've got a CSV file which has all the folders which need moving in. But I'm unsure how to automate it being read into a .bat script file? Any hints/clues anyone?? :)
 
assuming the full directories are in column A, in column B use ="copy "&A1&" C:\new folder"

Copy that down. Then copy column B. In notepad, paste special the values, save as .txt file then rename to .bat and run it.
 
Since you have posted in the PowerShell forum:

The following will move the entire contents of one folder to another location.

Code:
Move-Item C:\SourceDirectory\* C:\DestinationDirectory



I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top