Solved

copy for batch script not working

Posted on 2011-09-11
11
403 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, 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 37

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 53

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 37

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 69

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 69

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

773 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