Solved

Batch file with Variable directory Paths

Posted on 2014-01-16
10
375 Views
Last Modified: 2014-01-16
I have simple move command that I need to make into a batch file.

move "\company-nas\local\Shared\Sites\Property_A\Directory A" "\company-nas\local\Shared\Sites\Property_A\Directory B"

My issue is the Property_A is variable. So the next copy would be Property_B. So on and so forth. How can I make this into a batch script?
0
Comment
Question by:Vontech615
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 18

Expert Comment

by:x-men
Comment Utility
use "robocopy.exe" to copy folder and subfolder.
You can filter files, and schedule jobs.

more at:
http://technet.microsoft.com/en-us/library/cc733145.aspx
0
 
LVL 1

Author Comment

by:Vontech615
Comment Utility
Yes but the source and destination path's change. I've used robocopy before with the FOR command but not with variable paths.
0
 
LVL 1

Author Comment

by:Vontech615
Comment Utility
Basically, I need to know if my script can be 1 line or if I'm going to have to add a line for each Property name (Property_A, B, C, D, etc.)
0
 
LVL 10

Expert Comment

by:remmett70
Comment Utility
Is there some type of logic to know what the next Property value will be?
0
 
LVL 1

Author Comment

by:Vontech615
Comment Utility
No not really. They are alphabetical obviously but Names like ARP Manor, Bailey Lane, Cambridge, etc. etc.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 26

Expert Comment

by:pony10us
Comment Utility
Will this be run manually?  If so then you could have the batch file ask for the property name as input.
0
 
LVL 1

Author Comment

by:Vontech615
Comment Utility
I could run it manually, yes.
0
 
LVL 10

Expert Comment

by:remmett70
Comment Utility
Once Property_A\Directory_A is moved to Property_A\Directory_B, will the script ever need to do a another move of the same Property_A folder again?  If not, could create a log file to record what folders have been done.
0
 
LVL 26

Accepted Solution

by:
pony10us earned 500 total points
Comment Utility
Try this:

@echo off
set /p Property_ID= What is the name of the property?
move "\company-nas\local\Shared\Sites\Property_A\Directory A" "\company-nas\local\Shared\Sites\%Property_ID%\Directory B"

Open in new window

0
 
LVL 1

Author Comment

by:Vontech615
Comment Utility
That method works and should come in handy with other projects.  Thanks for the input.

Just fyi.  I had worked with someone else on this and ended up with this...

@echo
setlocal

for /f "tokens=*" %%a in ('dir /b /ad "\\company-nas\local\Shared\Sites\*" ') do (Move "\\company-nas\local\Shared\Sites\%%a\AR File Checks" ^
  "\\company-nas\local\Shared\Sites\%%a\Compliance")

Open in new window


This also works.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Sed question 2 44
Batch File to find and replace a string 15 89
Need help editing script 3 49
User profile Size Report 3 35
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now