Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

copy for batch script not working

Posted on 2011-09-11
11
Medium Priority
?
415 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 57

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 2000 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 71

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 71

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Can I legally transfer my OEM version of Windows to another PC?  (AKA - Can I put a new systemboard in my OEM PC?) Few of us are both IT and legal experts but we all have our own views of Microsoft's licensing rules and how they apply.  There are…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

688 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