Page 1 of 2 12>
Topic Options
#153319 - 2005-12-13 10:56 PM If Exist Ren & Copy
jszei Offline
Fresh Scripter
***

Registered: 2005-12-01
Posts: 17
Hey guys,

I am trying to rename a file on a PC if it exists then copy a file from a server to a PC as a new name. Here's what I've got but the syntax is wrong. Can anyone help?
Code:
  


Dim $mapir
$mapir="C:\Program Files\Common Files\System\Msmapi\1033"
If Exist $mapir +"\"mapir.dll
REN $mapir +"\"mapir.dll $mapir"\"mapir.old
COPY "\\mnc17p1s\NETLOGON\batch\mapirnew.dll" $mapir +"\" mapir.dll
End If
Code:
  



Thanks & try to hold back the laughs,
John

Top
#153320 - 2005-12-13 11:55 PM Re: If Exist Ren & Copy
StarwarsKid Offline
Seasoned Scripter
*****

Registered: 2005-06-15
Posts: 506
Loc: Oregon, USA
Looks like you'll want to use the MOVE command instead of REN. Also, ENDIF is one word in KiXtart.

Look in the Manual for more info on "MOVE".

Code:


Dim $mapir
$mapir="C:\Program Files\Common Files\System\Msmapi\1033\"

If Exist $mapir + "mapir.dll"
MOVE $mapir + "mapir.dll" $mapir + "mapir.old" /h /s
COPY "\\mnc17p1s\NETLOGON\batch\mapirnew.dll" $mapir + "mapir.dll"
EndIf

_________________________
let the wise listen and add to their learning,
and let the discerning get guidance- Proverbs 1:5

Top
#153321 - 2005-12-13 11:59 PM Re: If Exist Ren & Copy
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Where did you get REN from? Not the manual, I'm sure. You cannot be making up your own commands but you could create your own UDF.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#153322 - 2005-12-14 12:01 AM Re: If Exist Ren & Copy
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Oh, and your VBer roots are showing... it's EndIf, not End If.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#153323 - 2005-12-14 12:11 AM Re: If Exist Ren & Copy
jszei Offline
Fresh Scripter
***

Registered: 2005-12-01
Posts: 17
I ran your script through the editor & it doesn't work.
It dies here: If Exist $mapir + "mapir.dll" with invalid method/function call.
I thought the move command to rename was strictly Unix. It works within Kix for Windows as well? Yes, yes Microsoft has be by the collar.

Thanks,
John

Top
#153324 - 2005-12-14 12:16 AM Re: If Exist Ren & Copy
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Do you have a manual?
If so, look up the Exist() function!
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#153325 - 2005-12-14 12:17 AM Re: If Exist Ren & Copy
StarwarsKid Offline
Seasoned Scripter
*****

Registered: 2005-06-15
Posts: 506
Loc: Oregon, USA
Yes. Read the manual that comes with KiXtart(or at least search it for the function you're trying to perform). You will find a list of functions and their use and syntax. Sorry, I didn't test the code, just cleaned up your original code to the best of my ability.

My EXIST syntax was wrong.

After Reading the manual I found that the syntax is correct as follows:

Code:
 
If Exist ($mapir + "mapir.dll")


_________________________
let the wise listen and add to their learning,
and let the discerning get guidance- Proverbs 1:5

Top
#153326 - 2005-12-14 12:39 AM Re: If Exist Ren & Copy
jszei Offline
Fresh Scripter
***

Registered: 2005-12-01
Posts: 17
The corrected EXIST syntax works, thank you. You don't have to apologize, it's not like I could ever get upset at anyone for helping me. I do appreciate it and as this is the Starter's BB I would hope to be treated as a someone with very little knowledge *bows down to the greatness above*
Next in my debug I am getting Unknown or Unexpected Command Move.
Can't seem to find anything in the manual

Top
#153327 - 2005-12-14 12:41 AM Re: If Exist Ren & Copy
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
What version @KiX ?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#153328 - 2005-12-14 12:43 AM Re: If Exist Ren & Copy
jszei Offline
Fresh Scripter
***

Registered: 2005-12-01
Posts: 17
4.12
Top
#153329 - 2005-12-14 12:47 AM Re: If Exist Ren & Copy
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Starters forum or not... is no excuse not to read the manual!
Quote:

Fixes/enhancements in 4.20:
- Enhanced tokenizing engine

- Join() now takes a 3rd parameter: the number of elements of the array to join

- Added AScan()

- Added IIf()

- Added recursion ('/s') to COPY and DEL

- Added MOVE command (to move and/or rename files or directories)



_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#153330 - 2005-12-14 12:58 AM Re: If Exist Ren & Copy
jszei Offline
Fresh Scripter
***

Registered: 2005-12-01
Posts: 17
Moderator or not Les your tone sucks. Not just in this post but others I have read. Not all of us are as brilliant as you Les. I tried to show gratitude for the help given and all you seemed to do was stick your finger up at me. You should take notes from NTDOC, he is extremely polite, helpful and NOT CONDESCENDING. Take your bad day or life out on someone else.
Top
#153331 - 2005-12-14 01:23 AM Re: If Exist Ren & Copy
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Hey, I'm not having a bad day...

When SWK suggested you "Look in the Manual for more info on "MOVE"", had you said then that it was not in your manual, we would not have to wonder what version you are running.

Now, when you say "Can't seem to find anything in the manual", one needs to wonder what you really mean because I can find lots of good things in there, albeit in the 4.12 version, nothing on MOVE.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#153332 - 2005-12-14 06:48 AM Re: If Exist Ren & Copy
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
lol.
oh, btw, the 4.51 chm is now downloadable from kixtart.org/manual
_________________________
!

download KiXnet

Top
#153333 - 2005-12-14 04:00 PM Re: If Exist Ren & Copy
jszei Offline
Fresh Scripter
***

Registered: 2005-12-01
Posts: 17
Must be a bad life then. That would make sense since all your posts have that same, short "look somewhere else, why are you asking me" answer. Why do you think we're posting here. If you think you're educating don't become a teacher. If you have nothing to say but RTFM then don't reply to the posts. I hope someone makes you feel stupid for asking something you don't know, and I'm sure there is a lot you don't know. Oh, and thanks for the help.
Top
#153334 - 2005-12-14 07:41 PM Re: If Exist Ren & Copy
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I really don't know what your problem is. There is no detail in your profile that would lead me to believe that perhaps English is a second language or that there is some cultural sensitivity, so I must assume it is just a bad attitude.

I realize that beginners need to start somewhere and IMHO what better place to start than with the manual. I don't know how you expect to earn respect when you flagrantly ignore the manual with its fine examples and then ignore the good advice offered on this board.

I think you should reflect back upon your own work and think about what a supervisor would think of someone that just makes up commands and syntax that do not exist in the manual. By not doing proper research and simply posting to the board, you are likely to get the advice du jour from whoever happens to answer your post which may not prove to be the best advice in the end.

I recognize that I have a low tolerance for mediocrity but see nothing before this post that should illicit such a response from you.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#153335 - 2005-12-14 08:51 PM Re: If Exist Ren & Copy
jszei Offline
Fresh Scripter
***

Registered: 2005-12-01
Posts: 17
Couldn't resist a retort could you. Now you are revealing yourself as a racist with your reference to English as a second language. Who are you to knock anyone who might actually be able to speak two languages where English is the second. Your quip was not funny. Especially being from Canada where you can't decide which language is your own. My problem has been your response to my post from the beginning. It's rude. The only bad advice I got was from you. SWK offered good advice.
Les says "I recognize that I have a low tolerance for mediocrity". Recognition is the first step. Next take a look at your own life and realize how you can not tolerate yourself. Your arrogance is appaling. Please don't respond to my post anymore, I am tired of your less than mediocre dialogue.

Top
#153336 - 2005-12-14 09:03 PM Re: If Exist Ren & Copy
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Wow, calm down you guys. I'm sure nobody here is a true racist so there is no need calling people names like that. Some people might have a way of replying that could look like an insult but is not meant like that. I've had some good help out of les's replies in the past.

Let’s stop calling each other names and continue nice and polite please. We just had some threads here where this also came up and I hoped we put it to sleep and everybody was being nice again, guess not. If you take offence to a reply someone gave then be the stronger one and just ignore it. Please stop the name calling.



Edited by Mart (2005-12-14 09:04 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#153337 - 2005-12-14 10:44 PM Re: If Exist Ren & Copy
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Les said:
Quote:


I recognize that I have a low tolerance for mediocrity but see nothing before this post that should illicit such a response from you.





As an outside observer - I agree with Les's statement. jszei your taking these comments wrong (and way too personally). I can tell by your writing that your no dumby either. I've known Les for years now - can assure you that A) he's no racist and B) he knows what he's talking about. He just has a low tolerance for people asking questions about stuff thats clearly in the manual - thats all ;0)

Top
#153338 - 2005-12-14 10:51 PM Re: If Exist Ren & Copy
jszei Offline
Fresh Scripter
***

Registered: 2005-12-01
Posts: 17
My apologies Les. With all these people backing you up you must be a stand up guy. It just happens that my wife's native language is not english and is taking ESL courses. You struck a nerve.

If anyone is still willing to help me out after this my code is not renaming the file properly after updating Kix to 4.51.
Code:

Dim $mapir
$mapir="C:\Program Files\Common Files\System\MSMAPI\1033\"
If Exist ($mapir + "mapir.dll")
MOVE $mapir + "mapir.dll" $mapir + "mapir.old" /h /s
COPY "\\mnc17p1s\NETLOGON\batch\mapirnew.dll" $mapir + "mapir.dll"
EndIf



Thanks

Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 382 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.076 seconds in which 0.026 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org