Solved

copy for batch script not working

Posted on 2011-09-11
11
407 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 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 54

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to roll into all sub dirs 7 60
cloning computer 13 100
Need help modifying a script to help search for files with specific values in names 22 49
Windows updates batch files 7 102
Can you find a fax from a vendor you saved a decade ago in seconds? Have you ever cursed your PC under your breath during an audit because you couldn’t find the requested statement or driver history?  If you answered no to the first question or yes …
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
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…

713 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