Solved

Batch file with Variable directory Paths

Posted on 2014-01-16
10
399 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 18

Expert Comment

by:x-men
ID: 39785671
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
ID: 39785687
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
ID: 39785692
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

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

Author Comment

by:Vontech615
ID: 39785718
No not really. They are alphabetical obviously but Names like ARP Manor, Bailey Lane, Cambridge, etc. etc.
0
 
LVL 26

Expert Comment

by:pony10us
ID: 39785746
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
ID: 39785749
I could run it manually, yes.
0
 
LVL 10

Expert Comment

by:remmett70
ID: 39785756
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
ID: 39785793
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
ID: 39786715
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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

710 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