Solved

copy for batch script not working

Posted on 2011-09-11
11
401 Views
Last Modified: 2012-05-12
I have the following batch script below
this is for lotus symphony by the way
What works on this script is creating a new directory if the directory does not exist, but what I am trying to do now is copy over the com.ibm.symphony.ui.prefs file the folder "%userprofile%\IBM\Lotus\Symphony\.metadata\.plugins\org.eclipse.core.runtime\.settings\

However when I do do this, I get the filename COMIBM~1.PRE
But that file does have the same data

Any idea what I am doing wrong?

This is win xp
IF EXIST "%userprofile%\IBM\Lotus\Symphony\.metadata\.plugins\org.eclipse.core.runtime\.settings\" (
Copy C:\com.ibm.symphony.ui.prefs "%userprofile%\IBM\Lotus\Symphony\.metadata\.plugins\org.eclipse.core.runtime\.settings\" /N
) else (
MD "%userprofile%\IBM\Lotus\Symphony\.metadata\.plugins\org.eclipse.core.runtime\.settings\"
Copy "C:\com.ibm.symphony.ui.prefs" "%userprofile%\IBM\Lotus\Symphony\.metadata\.plugins\org.eclipse.core.runtime\.settings\" /N
)

Open in new window

0
Comment
Question by:mmercaldi
  • 3
  • 2
  • 2
  • +4
11 Comments
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 36520149
>> However when I do do this, I get the filename COMIBM~1.PRE

How do you know that COMIBM~1.PRE is the filename? Do you see that on the command prompt or else?
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 36520156
Hmm, when looking at your copy cmd, remove the /N and try again :)

" /N           Uses short filename, if available, when copying a file with a non-8dot3 name. "
0
 

Author Comment

by:mmercaldi
ID: 36520415
its there because thats the file that pops up in that folder.  Also it says it in command prompt
I also tried removing the /N command
0
 
LVL 51

Expert Comment

by:Bill Prew
ID: 36520536
One this to watch out for.  If you are running this BAT file from COMMAND instead of CMD, then as I recall it will use short file names rather than long.

~bp
0
 

Expert Comment

by:ryanjones
ID: 36520540
try using the xcopy command instead, I've always found it better.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 43

Accepted Solution

by:
Steve Knight earned 500 total points
ID: 36520899
btw no need to go to the trouble of checking dir exists, just hide any error is easier:

@echo off
set dir="%userprofile%....etc." (not going to type that out o mobile without copy/paste!)
md %dir% 2>nul
xcopy /d "c:\sourecdirpath\*.*" "%dir%"

that trys to make the dir and hides and error if there is one
then uses xcopy /d to copy any files from source dir that are newer to the destination one.

Steve


0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 36521140
As billprew says: what is your batch file called? batch_script.cmd or batch_script.bat?

I checked in W7 btw and there it makes no diffence (I have no XP available atm).
0
 
LVL 11

Expert Comment

by:paultomasi
ID: 36523873
Steve...


   md %dir% 2>nul


To be used cautiously... Will also return an error if target is an existing file i.e:


   COPY NUL file
   :
   MD file 2>NUL



0
 
LVL 68

Expert Comment

by:Qlemo
ID: 36524081
Paul,
That doesn't make much of a difference, as the copy will fail in both cases ...
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 36524107
And if we would check for existence, we would rather do:
@echo off
if not exists "%userprofile%\IBM\Lotus\Symphony\.metadata\.plugins\org.eclipse.core.runtime\.settings\" (
  md "%userprofile%\IBM\Lotus\Symphony\.metadata\.plugins\org.eclipse.core.runtime\.settings\"
)
Copy "C:\com.ibm.symphony.ui.prefs" "%userprofile%\IBM\Lotus\Symphony\.metadata\.plugins\org.eclipse.core.runtime\.settings\"

Open in new window

If you use xcopy with the same values, it will create the folder while copying, making it a single line:
xcopy "C:\com.ibm.symphony.ui.prefs" "%userprofile%\IBM\Lotus\Symphony\.metadata\.plugins\org.eclipse.core.runtime\.settings\"

Open in new window

0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 36527385
thanks. I guess that helped then!

Steve
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

It is only natural that we all want our PCs to be in good working order, improved system performance, so that is exactly how programs are advertised to entice. They say things like:            •      PC crashes? Get registry cleaner to repair it!    …
Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

757 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

18 Experts available now in Live!

Get 1:1 Help Now