Solved

copy for batch script not working

Posted on 2011-09-11
11
413 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
[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
  • 3
  • 2
  • 2
  • +4
11 Comments
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
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 38

Expert Comment

by:Gerwin Jansen, EE MVE
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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 56

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
 
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 38

Expert Comment

by:Gerwin Jansen, EE MVE
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 70

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 70

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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Step by step guide to Clean and Sort your windows registry! Introduction: Always remember: A Clean registry = Better performance = Save your invaluable time In this article we're going to clear our registry manually! Yes, manually! The e…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Suggested Courses

617 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